下午好。我正在写一个全局鼠标钩子。除了只为第一个鼠标事件调用钩子之外,一切似乎都工作得很好。一些代码:
// 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();
}
...