How to use SetClipboardViewer Function in Windows Service C#?

自闭症网瘾萝莉.ら 提交于 2019-12-12 05:15:17

问题


I am trying to get clipboard events using SetClipboardViewer. It works in a windows form when i override the function:

protected override void WndProc(ref Message m)

that belongs to the base class System.Windows.Forms.

The problem is that i want to do it in a windows service.

Does someone knows how to get the clipboard events in a windows service?

Thanks.


回答1:


Clipboard belongs to the session (actually the session's winstation), and there's no interactive user to do a clipboard copy in a service session. Of course you can have a clipboard listener process to relay the clipboard changes from an interactive session. You can use any protocol that works across the session, like sockets, shared memory or named pipe. Rdpclip.exe acts like one, though it sends data out via WTS virtual channels.

Some clipboard contents make sense when crossing the session boundary (e.g. CF_TEXT), some don't (e.g. CF_HDROP with paths from a mapped drive).



来源:https://stackoverflow.com/questions/14253313/how-to-use-setclipboardviewer-function-in-windows-service-c

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