本文整理匯總了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; }