SetWindowsHookEx problem on windows 64bit OS RRS feed

  • Question

  • Dears,

    This is a problem about global hook on 64bit OS, I need your help.

    I set up a global hook by using SetWindowsHookEx in a 32bit DLL to filter the keyboard and mouse operation for specified 32bit process, using process id for filtering condition.

    It works fine on all of 32bit operating system, but a curious phenomenon occurs on window vista 64bit and win7 64bit OS(I've not test it on WinXP 64 yet). When the 32bit dll contains global hook is loaded into memory by another 32bit process(it is also developed by me), then start target GUI process which is to be hooked, if focus is in the target GUI process window, it works fine(keyboard and mouse can not be used), if I focus on another 32bit process window which is not to be hooked, the keyboard and mouse can be used(this is fine), but if I focus on another 64bit process window, such as windows explorer, notepad. The keyboard and mouse can not be used!!!(this is the problem)

    Through some tracking on the log file, I found that when I change focus from target hooked process to another 64bit process window, the process id in MouseProc and KeyboardProc keeps the same one(the value is the hooked process id), but if I change focus from target hooked process to another 32bit process window, the process id will change as the new focused process.

    It is just curious and I don not know whether it is the mechanism of 64bit OS. 

    Why the process id not changing when focus is changed? Is there any solution to make a distinction between 32bit process and 64bit process in a global hooked procedure?

    Much appreciation for your help!!!


    Best wishes,




    Thursday, December 9, 2010 2:47 AM


All replies