我正在使用低级钩子(Hook),但无法确定按下了什么键。每个键的值都相同。这是我做错了吗?

勾方法

void hook() {

    /** this part is probably not important since I use global WH_KEYBOARD_LL, is that right? */
    HWND hwnd = FindWindow(NULL, "Vertices.exe");
    HINSTANCE instance = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
    /** end part */

    SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, instance /** or NULL ? */, NULL);
}

回调定义(我的应用中确实有内容)
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);

按下任意键给出的值
nCode:0 | wParam:0x100 | lParam:0x18fe14

只是wParam在按键向上变为0x101(按键向下为0x100)

最佳答案

KBDLLHOOKSTRUCT *kbdStruct = (KBDLLHOOKSTRUCT*)lParam;
:)

10-08 18:58