How do I tell if my application is running in an RDP session

后端 未结 4 795
旧时难觅i
旧时难觅i 2020-12-30 02:09

I have a .net winforms app which has a few animation effects, fade ins and scroll animations etc. These work fine however if I\'m in a Remote Desktop Protocol session the a

4条回答
  •  被撕碎了的回忆
    2020-12-30 02:53

    In addition to making the initial check to see if your desktop is running in a RDP session, you may also want to handle the situation where the remote session is connected or disconnected while your ap is running. You could have an app running on the console session and then someone could initiate a RDP connection to the console. Unless your application is periodically making the call to GetSystemMetrics, it's going to assume that it's not running as a terminal services session.

    You would have your app register for session update notificiations through WTSRegisterSessionNotification. That will allow your applicaiton to be immediately notified is a remote connection has been opened or closed to the desktop session that your application is running under. See here for some sample C# code.

    For a some good Delphi Win32 exampale code for using WTSRegisterSessionNotification, see this page.

提交回复
热议问题