Is there a way my program can determine when it's running on a Remote Desktop (Terminal Services)?
I'd like to enable an "inactivity timeout" on the program when it's running on a Remote Desktop session. Since users are notorious for leaving Remote Desktop sessions open, I want my program to terminate after a specified period of inactivity. But, I don't want the inactivity timeout enabled for non-RD users.
To view this remote desktop activity log, go to the Event Viewer. Under Applications and Services Logs -> Microsoft -> Windows -> Terminal-Services-RemoteConnectionManager > Operational.
Clients exist for most versions of Microsoft Windows (including Windows Mobile), Linux (for example Remmina), Unix, macOS, iOS, Android, and other operating systems. RDP servers are built into Windows operating systems; an RDP server for Unix and OS X also exists (for example xrdp).
GetSystemMetrics(SM_REMOTESESSION) (as described in http://msdn.microsoft.com/en-us/library/aa380798.aspx)
Here's the C# managed code i use:
/// <summary> /// Indicates if we're running in a remote desktop session. /// If we are, then you MUST disable animations and double buffering i.e. Pay your taxes! /// /// </summary> /// <returns></returns> public static Boolean IsRemoteSession { //This is just a friendly wrapper around the built-in way get { return System.Windows.Forms.SystemInformation.TerminalServerSession; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With