I have a .NET application where I need to be able to disallow running it on a Terminal Services server for licensing reasons. I am aware of the SystemInformation
API to determine if a program is running under a remote session (as detailed in this question for example). However, that API does not distinguish between an application running on a normal server which has the 2 allowed remote desktop sessions and a full-blown terminal server which might have 500 sessions running on it.
Is there a simple programmatic way that I can determine whether the application is running on a full-on terminal server?
I am fine with the assumption that more than 2 allowed sessions means a full-on terminal server, and I am also fine with P/Invoke if that's what's required.