兄弟们帮忙看看,SetWindowsHookEx的问题,谁知道答案?

magic7004 2011-06-06 02:20:03
下面是在某个网站看到的问题,我现在遇到了一摸一样的问题,可是那个网站上只有问题,没有答案。谁知道的,帮忙解释下,谢谢!

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?
...全文
96 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lactoferrin 2011-06-06
  • 打赏
  • 举报
回复
钩子句柄和窗口句柄公用一个句柄表,低16位是索引,因此最多65536个
把你的代码放上来,HInstance必须是KeyboardProc所在的模块

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧