Detecting the Remote Desktop Services environment
To optimize performance, it is good practice for applications to detect whether they are running in a Remote Desktop Services client session. For example, when an application is running on a remote session, it should eliminate unnecessary graphic effects, as described in Graphic Effects. If the user is running the application in a local environment, it is not as critical for the application to optimize its behavior.
The following example shows a function that returns TRUE if the application is running in a remote session and FALSE if the application is running on the console.
#include <windows.h> #pragma comment(lib, "user32.lib") BOOL IsRemoteSession(void) { return GetSystemMetrics( SM_REMOTESESSION ); }
For more information, see Run-time Linking to Wtsapi32.dll.
Send comments about this topic to Microsoft
Build date: 3/7/2012