从Windows服务全局键盘钩子

编程入门 行业动态 更新时间:2024-10-28 04:22:50
本文介绍了从Windows服务全局键盘钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有可能写在Windows(XP和7)服务的全球键盘挂钩? (使用SetWindowsHookEx函数并没有一个系统的服务工作)

Is it possible to write a global Keyboard Hook from windows(xp and 7) service ? ( using SetWindowsHookEx didn't work from a system service )

推荐答案

的文档 SetWindowsHookEx函数说:

,或在同一桌面与调用线程的所有线程。

or with all threads in the same desktop as the calling thread.

因此​​,你需要用相同的桌面关联(即使不考虑终端服务,并且会有多个桌面:正常的桌面,安全桌面(用于UAC和登录)和屏幕保护程序)。

So you need to be associated with the same desktop (and there will be multiple desktops even without considering terminal services: the normal desktop, the secure desktop (used for UAC and login) and the screen saver).

由于服务不带有交互式会话相关的(和,从Windows V6,不能),你就需要在用户的会话中的过程中做了钩,并通过命名管道与后端服务(如通信。 )。而且不要忘了测试,没有一登录,并且多个用户登录。

Since services are not associated with an interactive session (and, from Windows V6, cannot be) you'll need a process within the user's session to do the hooking, and communicate with the backend service (eg. via a named pipe). And don't forget to test with no-one logged in, and multiple users logged in.

更多推荐

从Windows服务全局键盘钩子

本文发布于:2023-11-08 10:46:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569172.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:钩子   全局   键盘   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!