1

下午好。我正在写一个全局鼠标钩子。除了只为第一个鼠标事件调用钩子之外,一切似乎都工作得很好。一些代码:

// Dll defined function
    extern "C" Q_DECL_EXPORT LRESULT MouseProc(int code, WPARAM wParam, LPARAM lParam)
    {
        qDebug() << "MouseProc";
        return TRUE;
    }

// Application code
    ...
        hLib = LoadLibrary(TEXT("ServerHook.dll"));
        HOOKPROC hookAddr = (HOOKPROC)GetProcAddress(hLib, "MouseProc");
        if (!hookAddr) {
            qDebug() << "Invalid hook proc " << GetLastError();
        }
        if ((WinInputHook::hookHandle = SetWindowsHookEx(
                    WH_MOUSE, hookAddr, hLib, 0))
                    == NULL) {
            qDebug() << "Invalid hook handle " << GetLastError();
        }
    ...
4

1 回答 1

1

您正在安装的挂钩(WH_KEYBOARD)“安装一个监控击键消息的挂钩程序”而不是鼠标

于 2012-05-11T11:19:07.403 回答