SetWindowsHookEx in C#

SetWindowsHookEx specifies the last two parameters thusly: hMod [in] Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the … Read more

SetWindowsHookEx failing in .NET 4.0 on 32-bit machine with “module not found”?

Yup, I think you understand what’s going on. SetWindowsHookEx() requires a valid module handle, and verifies it, but it doesn’t actually use it when you set a low-level hook. You just need a valid handle, it doesn’t matter which specific one. Calling LoadLibrary(“user32.dll”) is a good way to get a handle, that DLL will always … Read more