MachineName for remote machine using Remote Desktop

笑着哭i 提交于 2019-12-06 11:47:48

问题


I'm writing a C# program where it would be useful to see if someone is running the program via remote desktop and if so, the machine name where the remote desktop is running.

I can get the former using SystemInformation.TerminalServerSession

But is there any way to get the name of the remote machine?


回答1:


I think the Remote Desktop Services API will do what you want... http://msdn.microsoft.com/en-us/library/aa383468(v=VS.85).aspx

And the following example may help too - http://community.citrix.com/display/xa/How+to+get+client+IP+address+and+client+hostname+using+Terminal+Services+API




回答2:


You can certainly use WTSQuerySessionInformation to get this information, though if you'd prefer not to deal with the P/Invokes, you could also use the Cassia library: new TerminalServicesManager().CurrentSession.ClientName.



来源:https://stackoverflow.com/questions/5821197/machinename-for-remote-machine-using-remote-desktop

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