Home > Windows API > Is my application running on a remote session?

Is my application running on a remote session?

Is there any way to find out if our application is being run using a terminal services client session? Well what is a terminal service? It’s a program that creates a local session for a remote PC, one such terminal services application is “mstsc”. If you want to connect to a remote pc you just have to enter

mstsc -v name_of_pc

Enter password and you are virtually working on the remote pc, you can run any application on that pc and this is called a terminal service client session. So is there a way to know whether our application is being run using a terminal service or directly on the local pc.

Yes use good old faithful windows API called GetSystemMetrics along with SM_REMOTESESSION index. If return value is non-zero then the application is being run using a terminal service.

An e.g. call

if( ::GetSystemMetrics( SM_REMOTESESSION ))
{
     MessageBox( "Our application is being run using a remote session" );
}

Hope my understanding is correct. 🙂

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: