I want to set a global hook that keeps track of which application is active.
In my main program, I do the following:
HMODULE mod=::GetModuleHandle(L"HookProcDll");
HHOOK rslt=(WH_CALLWNDPROCRET,MyCallWndRetProc,mod,0);
The hook procedure, which is called MyCallWndRetProc, exists in a separate dll called HookProcDll.dll. The hook routine keeps track of the message WM_ACTIVATE.
The fact is that the code is held in the line where I set the hook, i.e. in the line where I'm calling ::SetWindowsHookEx. And then Windows becomes unresponsive, my taskbar disappears, and I leave the desktop blank. Then I have to reset the computer.
What is doing wrong, why is Windows not responding? and also Do I need to enter HookProcDll.dll in every process to set the global hook, and how can I do this?
source
share