Sendmessage from NT Service to remote desktop session

让人想犯罪 __ 提交于 2019-11-30 20:26:12

问题


How can i send a sendmessage & postmessage from nt service to an application which launched in a remote desktop session? currently i temporarily solved this problem via udp communications between applications.


回答1:


You cannot send messages across session boundaries. So you need an IPC solution like TCP/IP, sockets, named pipes etc.




回答2:


Make a program that does a sendmessage/postmessage:

program sendit; uses converters; begin exitcode:=sendmessage(covert1(paramstr(1)),convert2( .... etc end.

Then run it in the right session with CreateProcessAsUser. You can wait (WaitForSingleObject) for the program to exit, at which point the sendmessage completed. It's very slow though :).

You can also go with pipes/IPC, but you can still launch the "server" using CreateProcessAsUser. Use Jwa for getting tokens and such.

And use better names than I just did :).




回答3:


Use the WTSSendMessage api: Displays a message box on the client desktop of a specified Remote Desktop Services session.

http://msdn.microsoft.com/nl-nl/library/windows/desktop/aa383842(v=vs.85).aspx

Or use the Jedi Windows Security library which wraps this in nice delphi like objects



来源:https://stackoverflow.com/questions/16501925/sendmessage-from-nt-service-to-remote-desktop-session

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