开发者

How to detect if there is an active connection to a server made through rdc?

I need to write a program (in C#), to run in the client local machine, that will show a list of our windows servers (Sort of the server names in a ListBox) and let the user choose and subsequently connect via RDC. However, the program needs to know if the user is already connected to one of the listed servers, in which case the client will be advised to first disconnect from previous session before continuing. The question is how to detect if there is already such an active connection in the user l开发者_高级运维ocal machine? And better yet, would it be possible to detect the ip address of this server, so that we can ignore the connection if it is not in one of our servers?


You mean like "query session" command-line? I guess you can do it with WMI, look around the Win32_LogonSession class.


The unmanaged API function WTSEnumerateSessions lets you query a remote server for all current sessions. As a starting point for C#, there is of course a P/Invoke signature at pinvoke.net

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜