Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programatically recognizing that a windows RDP session is currently in progress

I have a virtual machine on a remote computer, to which I connect using Windows RDP. We have several people using this machine, all with the same Windows login.

A problem that often occurs, is that when someone connects to the machine he throws out another person currently connected to it.

I would like to write a small application letting you know if someone is currently using the machine, but I don't know how to use the API in order to achieve this. Please note again that everyone uses the same login.

Any ideas?

like image 298
user181218 Avatar asked Sep 15 '25 03:09

user181218


1 Answers

You can use WTSEnumerateSessionsEx function:

http://msdn.microsoft.com/en-us/library/windows/desktop/ee621014%28v=vs.85%29.aspx

You will receive list of sessions.If there some in 'Active' state RDP connection is realy in use.

WTS_CONNECTSTATE_CLASS : http://msdn.microsoft.com/en-us/library/windows/desktop/aa383860%28v=vs.85%29.aspx

Similar result you can get with built-in command "QWINSTA"

like image 80
rkosegi Avatar answered Sep 16 '25 18:09

rkosegi