Getting Terminal Services Session ID in .NET?

Can anyone help me find the .NET equivalent of the following C ++ code:

DWORD session_id; ProcessIdToSessionId(GetCurrentProcessId(), &session_id); 

I am trying to find the current terminal services session number to uniquely name the named pipe that two programs use within the same session to communicate with each other. But the only information I can find when searching for .NET sessions is web material.

Thanks.

+6
sessionid terminal-services
source share
1 answer

Indeed, this functionality is provided entirely in the BCL ( System.Diagnostics ) System.Diagnostics :

 var sessionId = Process.GetCurrentProcess().SessionId; 

See the SessionId on MSDN for more information.

+14
source share

All Articles