I'd like to get the information of remote session source at the destination server with this function*1.

WTSQuerySessionInformation function (Windows)

It can be written by C# with DllImport. The value of WTS_CURRENT_SESSION is uint.MaxValue .

gist.github.com

It takes some doing because the structure of ppBuffer is changed depending on the specified value in WTSInfoClass . Here is a struct when WTSInfoClass is WTSClientAddress .

WTS_CLIENT_ADDRESS structure (Windows)

If you get all the sessions except itself, you can use this function.

WTSEnumerateSessions function (Windows)