兄弟们帮忙看看,SetWindowsHookEx的问题,谁知道答案?
下面是在某个网站看到的问题,我现在遇到了一摸一样的问题,可是那个网站上只有问题,没有答案。谁知道的,帮忙解释下,谢谢!
Hi!
most of the time the following works, but sometimes it doesn't. It is as if Windows XP has a limit on the number of hooks or something like that. Incidentally, when this doesn't work, the Windows Start Menu starts to behave strangely (can't navigate it normally using the keyboard or mouse any more), so the system seems to really have reached a limit. But what LIMIT???
HookHandle=SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) KeyboardProc,
HInstance, threadid);
HInstance and threadid are always correct. It's just that sometimes Windows is able to install the hook and sometimes it isn't.
If it fails, GetLastError is 126 (Module not found). The module that isn't found could either be the caller (a DLL), or the host application which is being hooked (an EXE). I don't know which one this error refers to. Obviously both modules exist, and all module-related handles and IDs are correct.
Any ideas?