📄 console.java
字号:
//******************************************************************
// Released under the DevelopMentor OpenSource Software License.
// Please consult the LICENSE file in the project root directory,
// or at http://www.develop.com for details before using this
// software.
//******************************************************************
package org.jawin.donated.win32;
import java.io.IOException;
import org.jawin.COMException;
import org.jawin.FuncPtr;
import org.jawin.ReturnFlags;
import org.jawin.io.LittleEndianOutputStream;
import org.jawin.io.NakedByteStream;
import org.jawin.marshal.GenericStub;
import org.jawin.marshal.StructConverter;
public class Console {
static final int mtokenHandlerRoutine =
GenericStub.registerCustomString("1I:I:");
public static boolean SetConsoleCtrlHandler(HandlerRoutine rt, boolean add)
throws COMException, IOException
{
FuncPtr fp = new FuncPtr("KERNEL32.DLL", "SetConsoleCtrlHandler");
NakedByteStream nbs = new NakedByteStream();
LittleEndianOutputStream leos = new LittleEndianOutputStream(nbs);
leos.writeInt(0); //offset of callback in obj array
leos.writeInt(add ? 1 : 0);
byte[] res = fp.invoke("T2." + mtokenHandlerRoutine + "I:I:",
8, nbs, new Object[] {rt}, ReturnFlags.CHECK_FALSE);
return (StructConverter.bytesIntoInt(res, 0) != 0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -