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,重启,解决。

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

  • 相关阅读:
    JavaScript 获取CSS媒体查询信息
    拖拉事件
    JavaScript 中的正常任务与微任务
    IOS 采用https 协议访问接口
    将类数组 转化为数组
    合并两个数组的方法
    base64转码
    Promise 异步执行的同步操作
    proxy set 拦截
    VIm 一些常用的设置
  • 原文地址:https://www.cnblogs.com/songr/p/5131655.html
Copyright © 2011-2022 走看看