从Windows服务全局键盘钩子钩子、全局、键盘、Windows

由网友(9.冷心且迷人)分享简介:是否有可能写在Windows(XP和7)服务的全球键盘挂钩? (使用SetWindowsHookEx函数并没有一个系统的服务工作)Is it possible to write a global Keyboard Hook from windows(xp and 7) service ? ( using SetWin...

是否有可能写在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.

阅读全文

相关推荐

最新文章