Determine if a program is running on a Remote Desktop

Kluge picture Kluge · Oct 1, 2008 · Viewed 15k times · Source

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.

Answer

Franci Penov picture Franci Penov · Oct 1, 2008

GetSystemMetrics(SM_REMOTESESSION) (as described in http://msdn.microsoft.com/en-us/library/aa380798.aspx)