Windows钩子只被调用一次

时间:2012-05-11 10:48:17

标签: windows qt dll hook

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

// 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();
        }
    ...

1 个答案:

答案 0 :(得分:1)