Sendmessage from NT Service to remote desktop session

ぐ巨炮叔叔 提交于 2019-12-01 01:21:08

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

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 :).

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

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