Nov 202008
 

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. 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.