低级键盘钩子,在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_USER\Control Panel\Desktop
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,重启,解决。
这个地方的问题说明,钩子的处理一定要快。其次超时的值应该要记得设置。最好是程序中进行设置一下。
低级键盘钩子,在WIN7以上版本的问题的更多相关文章
- C#键盘钩子 鼠标钩子
最新对C#模拟键盘按键,鼠标操作产生了兴趣.特从网上收集了一些常用的API用来调用键盘,鼠标操作. class Win32API { #region DLL导入 /// <summary> ...
- 基于C#实现的HOOK键盘钩子实例代码
本文所述为基于C#实现的HOOK实例,该实例可用来屏蔽系统热键.程序主要实现了安装钩子.传递钩子.卸载钩子等功能.在传递钩子中:<param name="pHookHandle&quo ...
- 2.添加键盘钩子。向进程中注入dll
学习笔记 1.首先要建立mfc的动态链接库.在def文件中放入要导出的函数名. 2.添加函数如下 //安装钩子 //HHOOK SetWindowsHookEx( // int idHook,//钩子 ...
- C#鼠标键盘钩子
using System;using System.Collections.Generic; using System.Reflection; using System.Runtime.Interop ...
- C# 键盘钩子
p{ text-align:center; } blockquote > p > span{ text-align:center; font-size: 18px; color: #ff0 ...
- 在WPF中快速实现键盘钩子
大部分的时候,当我们需要键盘事件的时候,可以通过在主窗口注册KeyBinding来实现,不过,有的时候我们需要的是全局键盘事件,想在任何一个地方都能使用,最开始的时候我是通过键盘钩子来实现的, 不过键 ...
- Win7各个版本之间的区别
Windows7包含6个版本,分别为Windows7 Starter(初级版).Windows7 Home Basic(家庭普通版).Windows7 Home Premium(家庭高级版).Wind ...
- WPF 利用键盘钩子来捕获键盘,做一些不为人知的事情...完整实例
键盘钩子是一种可以监控键盘操作的指令. 看到这句话是不是觉得其实键盘钩子可以做很多事情. 场景 当你的程序需要一个全局的快捷键时,可以考虑使用键盘钩子,如大家常用qq的截图快捷键,那么在WPF里怎么去 ...
- 钩子编程(HOOK) 安装进程内键盘钩子 (1)
摘要:钩子能够监视系统或进程中的各种事件消息.截获发往目标窗体的消息并进行处理.这样,我们就能够在系统中安装自己定义的钩子,监视系统中特定事件的发生.完毕特定的功能,比方截获键盘.鼠标的输入.屏幕取词 ...
随机推荐
- PJzhang:钓鱼域名生成工具urlcrazy
猫宁!!! www.baidu.com和www.baibu.com是不是很相似,urlcrazy可以自动生成一大批. 这款工具的作者是Andrew Horton 工具下载地址: http://www. ...
- Mybatis插件之Mybatis-Plus(SpringBoot)
这边只在SpringBoot下进行简单查询的测试,接下来会博客会介绍增删改的操作. 数据库表结构如下: 开始测试: 1.新建工程(trymp_springboot)并把项目结构建立好 2.导入pom. ...
- AndroidStudio布局编辑器强制刷新布局界面
用AndroidStudio布局编辑器编辑界面的时候,在selector里调整按钮的颜色,调整后的颜色经常无法实时显示在布局编辑器里,每次都重新运行程序查看界面又非常麻烦和低效,可以用以下方法解决: ...
- SQL Server数据库语法(一)
--创建数据库 DB_CYITcreate database DB_CYITON(name='DB_CYIT',--主文件逻辑名称filename='G:\data\DB_CYIT.mdf', --文 ...
- springboot简易上传下载
1.导入上传下载依赖: <dependency> <groupId>commons-fileupload</groupId> <artifactId>c ...
- LC 387. First Unique Character in a String
题目描述 Given a string, find the first non-repeating character in it and return it's index. If it doesn ...
- LC 416. Partition Equal Subset Sum
题目 Given a non-empty array containing only positive integers, find if the array can be partitioned i ...
- 编写函数实现strcmp( )函数功能
strcmp(字符串1,字符串2) 作用是比较字符串1和字符串2.两个字符串从左至右逐个字符比较(按照字符的ASCII码值的大小)(即减法比较),直到字符不同或者遇见’\0’为止 如果全部字符都相同, ...
- 【转】Entity Framework 6 Code First 实践系列(1):实体类配置-根据依赖配置关系和关联
本文转自:http://www.cnblogs.com/easygame/p/3622893.html EF实体类的配置可以使用数据注释或Fluent API两种方式配置,Fluent API配置的关 ...
- k8s组件通信或者创建pod生命周期
Kubernetes 多组件之间的通信原理: apiserver 负责 etcd 存储的所有操作,且只有 apiserver 才直接操作 etcd 集群 apiserver 对内(集群中的其他组件)和 ...
