user181218
user181218

Reputation: 1685

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?

Upvotes: 4

Views: 1471

Answers (1)

rkosegi
rkosegi

Reputation: 14638

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"

Upvotes: 3

Related Questions