简体   繁体   English

com.sun.jna.Pointer无法转换为com.sun.jna.platform.win32.WinDef.LPARAM

[英]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.

相关问题 Pointer(long)在com.sun.jna.Pointer中不是公共的; 无法从外部包访问 - Pointer(long) is not public in com.sun.jna.Pointer; Cannot be accessed from outside package JNA:com.sun.jna.platform.win32.Win32Exception-访问被拒绝 - JNA:com.sun.jna.platform.win32.Win32Exception- access denied java.lang.UnsatisfiedLinkError:无法获取com.sun.jna.Pointer类(神经技术Megamatcher SDK) - java.lang.UnsatisfiedLinkError: Can't obtain class com.sun.jna.Pointer (Neurotechnology Megamatcher SDK) Java Glassfish java.lang.IllegalAccessError:尝试访问glassfish 3.1.2.2上的方法com.sun.jna.Pointer - Java Glassfish java.lang.IllegalAccessError: tried to access method com.sun.jna.Pointer on glassfish 3.1.2.2 使用 Eclipse 获取 NoClassDefFoundError -> com/sun/jna/platform/win32/Psapi - Getting NoClassDefFoundError -> com/sun/jna/platform/win32/Psapi with Eclipse CreateProcessAsUser 方法中的 hToken (com.sun.jna.platform.win32.WinNT.HANDLE) 是什么。 如何使用 windowsIdentity 对象检索它 - What is hToken (com.sun.jna.platform.win32.WinNT.HANDLE) in CreateProcessAsUser method. How to retrieve it using windowsIdentity Object 在 ubuntu 中使用 ghost4j 获取 NoClassDefFoundError:com/sun/jna/win32/StdCallLibrary$StdCallCallback - Getting NoClassDefFoundError: com/sun/jna/win32/StdCallLibrary$StdCallCallback using ghost4j in ubuntu 无法使用 JNA:com.sun.jna.Library is not access - Can not use JNA: com.sun.jna.Library is not accessible axet / desktop:线程“main”中的异常java.lang.NoClassDefFoundError:com / sun / jna / Platform - axet/desktop: Exception in thread “main” java.lang.NoClassDefFoundError: com/sun/jna/Platform com.sun.jna.Memory中返回字符串会导致JVM崩溃 - return string in com.sun.jna.Memory causes JVM crash
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM