Hello everyone.
Since some time now, I've been experimenting with hooks. I've been trying to intercept WM_PAIT- and WM_ERASEBKGND messages sent to the desktop window, but I can't get the hook to work.
As I understand, one can set a system-wide hook to a specified module's WndProc-method by using SetWindowsHookEx, passing the module's HINSTANCE along. However, when I try to pass the desktop's HINSTANCE (obtained calling GetWindowLong), SetWindowsHookEx returns NULL. I used a sample ErrorExit method found on MSDN to show me the actual problem (it translates an error message from GetLastError into a readable error message), and it claims SetWindowsHookEx cannot find the specified module.
I've checked the instance handle returned by GetWindowLong in Spy++, and it appears to be correct. Does anyone know what the problem might be here? Could it be that hooking the desktop window's functions is some sort of access violation?
Regards,
David