The problem you have is that each dll will have a seperate copy of hKeyboardHook......in the process of the app that creates the hook, it will be valid, but in all other instances if will be void........
Many compilers offer a global memory option for dlls - kind of like a static variable in a c++ class - you can have as many dlls running in the system as you need, but they all refer to one area of system memory.....in that shared area, you place the HHOOK
For VC++ you use;
Now every dll uses the same HHOOK......
#pragma data_seg(".syshook") //Set shareable segment
HHOOK hKeyboardHook = NULL; //Handle to my hook
#pragma comment(linker, "/section:.syshook,rws")
Also add to this that the hook procedure (when called) exists in another process.........that means all shared handles (file...etc) are unusable (and you cant share them accross process boundries as you dont have a list of the processes that need them)...they way I get around this is for the launching app to open a MailSlot (CreateMailSlot()) and then create a thread to recieve messages......then I use CreateFile() in the hook dll to get a handle to the Mailslot (which is usable in my process) and write output to it.......