So I can set a global low level keyboard hook from within a DLL pretty easily, but does it actually load that DLL into every process? How is it then, "Global" ?

Any useful insight into the way this works?

I use the command line program "tasklist" with the /M option to view loaded .DLLs and I don't even see the global hook DLL loaded in my app.

Something strange going on?

Also I might be statically linking to the DLL...

SetWindowsHookEx has the following parameter

[in] HINSTANCE hMod

This MUST be the module handle of the DLL within which the Keyboard procedure is defined.
There is another item in the remarks of SetWindowsHookEx documentation.

Before terminating, an application must call the UnhookWindowsHookEx function to free system resources associated with the hook.

This implies that the process that sets the hook MUST continue running while the hook is in place and unhook when it terminates.

Sorry dex that didn't help.

But, I'll give a try to dynamic linking.

Do you know the difference between static and dynamic linking?

My statement:

This MUST be the module handle of the DLL within which the Keyboard procedure is defined.

means that you MUST USE A DLL == Dynamic Linked Library.

The Keyboard Procedure MUST be in that DLL.
Use GetModuleHandle to retrieve the value to use in the hMod parameter of the SetWindowsHookEx API.

Use GetProcAddress to retrieve the value to pass as the HookProc parameter.

I hope that is sufficiently explicit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.