Capturing KeyPress Event in WIndow Service

馋奶兔 提交于 2020-01-02 14:31:33

问题


I am trying to create a window service to create a small keylogger application. I am new to Windows services and my sole purpose is to learn.

How can I obtain all the events that are available in Winforms, but in a Windows service?

I've tried searching on Google, but I'm unable to find out how to do this. I'm getting many references to keyhook DLLs.


回答1:


Windows Services are not form based therefore you cannot do it that way.... Have a look here for an example of how to create a Windows Service that kills other windows.

A window service is not an ideal spot to place a form on... think of a daemon under Linux/Unix variants - they do not have a graphical display nor interact with the user as such and hence would be 'headless' for want a word for it as there's no interaction whatsoever, and furthermore, a service would be running under a system service account....

Speaking of Keyloggers, it does not work like that - you need to hook into the global keyboard hook and intercept the keys, an example of such a thing is here.

But then the question will arise for what purpose, gather data, etc - possibly AV's will flag them as malware... If you are doing it for yourself - that's good...but to maliciously place it on another computer without that user knowing about it is very iffy and could end up in court for invasion of privacy, in terms of local laws etc.



来源:https://stackoverflow.com/questions/3595993/capturing-keypress-event-in-window-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!