2

Have been reading a lot about this one and the picture just gets muddier. I have a 32-bit app that installs a KeyboardHook to wait for a global hotkey and wake up. Running it on Win 7 x64 edition I notice it hangs Outlook x64 edition when the hotkey is pressed.

So I did some research and it looks like 32-bit keyboard hooks aren't even supposed to work in 64 bit apps. Time for more testing...

They hotkey works fine in 64-bit notepad, wordpad, and sticky notes. I verified that these are 64-bit apps since they don't have "*32" next to them in Task Manager. Doesn't hang the app and it does what it's supposed to. But wait... a 32-bit hook dll can't be loaded into a 64-bit app, right?

A look at Process Explorer shows the hook dll isn't even loaded into the notepad process! (If I run the 32-bit notepad.exe from WOW64 directory, I can see the dll loaded into the process, so I know I'm using the tools right).

So the Outlook hanging issue might or might not be related, but why is the hook even working at all in 64-bit notepad?

Nicholas
  • 447
  • 1
  • 4
  • 18
  • 2
    There are *two* keyboard hook types. The low-level one doesn't require DLL injection. – Hans Passant Apr 12 '11 at 00:32
  • Thanks for that tip. I should look into low level hooking. Currently I'm using SetWindowsHookEx() with WH_KEYBOARD. Now I'm exploring RegisterHotKey() which doesn't seem to require a DLL either. – Nicholas Apr 12 '11 at 03:43
  • Looking into and testing WH_KEYBOARD_LL, it seems that it DOES require dll injection. I can't get the hook to register and numerous references online say that the DLL is required. Ideas? – Nicholas Apr 12 '11 at 19:26
  • 1
    Ok, got WH_KEYBOARD_LL working in the same process. hMod parameter has to be set using GetModuleHandle(NULL). Seemed contrary to the docs but it's working. Thanks for the tip! – Nicholas Apr 12 '11 at 21:23

1 Answers1

0

I have a 32-bit app that installs a KeyboardHook to wait for a global hotkey and wake up.

If that's your ultimate goal, then it's simpler and less of an impact on the system to just use RegisterHotKey.

Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175