[英]com.sun.jna.Pointer cannot be cast to com.sun.jna.platform.win32.WinDef.LPARAM
Error: 错误:
error:com.sun.jna.Pointer connot be cast to com.sun.jna.platform.win32.WinDef.LPARAM error location:return User32.INSTANCE.CallNextHookEx(hHook, nCode, wParam, keyInfo.getPointer());
错误:com.sun.jna.Pointer不能转换为com.sun.jna.platform.win32.WinDef.LPARAM错误位置:返回User32.INSTANCE.CallNextHookEx(hHook,nCode,wParam,keyInfo.getPointer());
Code: 码:
HMODULE hMod = Kernel32.INSTANCE.GetModuleHandle(null);
HOOKPROC lpfn = new LowLevelKeyboardProc()
{
int count = 1;
public LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT keyInfo)
{
System.out.println("nCode =" + nCode + ", wParam =" + wParam
+ ", vkCode=" + keyInfo.vkCode);
count++;
if (count > 100)
{
quit = true;
}
return User32.INSTANCE.CallNextHookEx(hHook, nCode, wParam, keyInfo.getPointer());
}
};
You need to manually construct the LPARAM
from the pointer's value as seen in the JNA KeyHook example . 您需要从指针的值手动构造
LPARAM
,如JNA KeyHook示例所示 。
Pointer ptr = keyInfo.getPointer();
long peer = Pointer.nativeValue(ptr);
return User32.INSTANCE.CallNextHookEx(hHook, nCode, wParam, new LParam(peer));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.