|Date:||April 25, 2005 / year-entry #103|
|Summary:||The SetWindowsHookEx function accepts a HINSTANCE parameter. The documentation explains that it is a handle to the DLL containing the hook procedure. Why does the window manager need to have this handle? It needs the handle so it knows which DLL to load into each process when the hook fires. It injects the DLL you...|
It needs the handle so it knows which DLL to load into each process when the hook fires. It injects the DLL you pass, then calls the function you pass. Clearly the function needs to reside in the DLL you pass in order for its code to be there when the window manager calls it.
This is also why hook functions must reside in DLLs. You can't load an EXE into another EXE.
Okay, armed with this information, perhaps you can solve this person's problem with global hooks.
<-- Back to Old New Thing Archive Index