问题
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