How to know if wpf app is in terminal services ses

2019-04-02 09:28发布

问题:

Is there an equivalent to

SystemInformation.TerminalServerSession in wpf?

I want to know if the current wpf application is running in a terminal server session. Thanks

回答1:

You could use the SystemParameters class to query system settings, especially the SystemParameters.IsRemoteSession property to get a value that indicates whether the calling process is associated with a Terminal Services client session (like SystemInformation.TerminalServerSession property).



回答2:

Just add a reference to System.Windows.Forms Since you are not messing with the UI you don't need anything special.

  System.Diagnostics.Debug.WriteLine(System.Windows.Forms.SystemInformation.TerminalServerSession.ToString());