zoukankan      html  css  js  c++  java
  • 低级键盘钩子,在WIN7以上版本的问题

    最近在项目用到低级键盘钩子。发现一个很奇怪的事情,在开发环境和测试环境下都正常运行的键盘钩子,

    到了现场环境,总是偶发性出现 键盘钩子不能用了,而且退出时产生1404 错误。

    后经过阅读MSDN 的Remark

    An application installs the hook procedure by specifying the WH_KEYBOARD_LL hook type and a pointer to the hook procedure in a call to the SetWindowsHookEx function.

    This hook is called in the context of the thread that installed it. The call is made by sending a message to the thread that installed the hook. Therefore, the thread that installed the hook must have a message loop.

    The hook procedure should process a message in less time than the data entry specified in the LowLevelHooksTimeout value in the following registry key:

    HKEY_CURRENT_USERControl PanelDesktop

    The value is in milliseconds. If the hook procedure does not return during this interval, the system will pass the message to the next hook.

    Note that debug hooks cannot track this type of hook.

    发现是现场的机器没有 Lowlevelhookstimeout 这个注册表项目,增加,修改值为10000,重启,解决。

    这个地方的问题说明,钩子的处理一定要快。其次超时的值应该要记得设置。最好是程序中进行设置一下。

  • 相关阅读:
    Java中的流
    多种日志收集工具比较
    UML类图几种关系的总结
    从数组中找出第K大的数
    数组各种排序算法和复杂度分析
    时间复杂度和空间复杂度
    Java Classloader原理分析
    WebSocket
    TCP/IP详解--TCP连接中TIME_WAIT状态过多
    TCP协议
  • 原文地址:https://www.cnblogs.com/songr/p/5131655.html
Copyright © 2011-2022 走看看