Click here to Skip to main content
15,914,398 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I need to know if my application is running under a remote desktop/connection session. How can I di it?
Thanks in forward
Posted

1 solution

I know you asked for native C++, but .NET has SystemInformation.TerminalServerSession. Worst case you could write a thin C++/CLI DLL that returns this value to you.

http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.terminalserversession.aspx[^]

[Update]
----------

Sorry, but you don't need to use .NET at all.

See http://msdn.microsoft.com/en-us/library/aa380798(v=vs.85).aspx[^]

Code snippet from that link:

C++
#include <windows.h>
#pragma comment(lib, "user32.lib")

BOOL IsRemoteSession(void)
{
   return GetSystemMetrics( SM_REMOTESESSION );
}
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 23-Apr-11 22:35pm    
You finally answered, my 5.
--SA
wokaka 22-Feb-13 1:54am    
I have tested this demo, But I found it doesn't work when I use remote desktop help contorl

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900