本文整理汇总了Java中com.sun.jna.Pointer.nativeValue方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.nativeValue方法的具体用法?Java Pointer.nativeValue怎么用?Java Pointer.nativeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.Pointer
的用法示例。
在下文中一共展示了Pointer.nativeValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isProcessActive
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* @see NativeCalls#isProcessActive(int)
*/
@Override
public boolean isProcessActive(final int processId) {
try {
final Pointer procHandle =
Kernel32.OpenProcess(Kernel32.PROCESS_QUERY_INFORMATION, false, processId);
final long hval;
if (procHandle == null
|| (hval = Pointer.nativeValue(procHandle)) == Kernel32.INVALID_HANDLE || hval == 0) {
return false;
} else {
final IntByReference status = new IntByReference();
final boolean result = Kernel32.GetExitCodeProcess(procHandle, status) && status != null
&& status.getValue() == Kernel32.STILL_ACTIVE;
Kernel32.CloseHandle(procHandle);
return result;
}
} catch (LastErrorException le) {
// some problem in getting process status
return false;
}
}
示例2: killProcess
import com.sun.jna.Pointer; //导入方法依赖的package包/类
/**
* @see NativeCalls#killProcess(int)
*/
@Override
public boolean killProcess(final int processId) {
try {
final Pointer procHandle =
Kernel32.OpenProcess(Kernel32.PROCESS_TERMINATE, false, processId);
final long hval;
if (procHandle == null
|| (hval = Pointer.nativeValue(procHandle)) == Kernel32.INVALID_HANDLE || hval == 0) {
return false;
} else {
final boolean result = Kernel32.TerminateProcess(procHandle, -1);
Kernel32.CloseHandle(procHandle);
return result;
}
} catch (LastErrorException le) {
// some problem in killing the process
return false;
}
}
示例3: getStdInputHandle
import com.sun.jna.Pointer; //导入方法依赖的package包/类
private static Pointer getStdInputHandle() throws IOException {
Pointer handle = kernel32.GetStdHandle(Kernel32Defs.STD_INPUT_HANDLE);
if (Pointer.nativeValue(handle) == 0 || Pointer.nativeValue(handle) == Kernel32Defs.INVALID_HANDLE_VALUE) {
throw new IOException("GetStdHandle(STD_INPUT_HANDLE) failed."); }
return handle; }