How can I tell if a user is running in a terminal services environment?
Posted on 2005-04-28
Today, our software product ran into a problem with terminal services environments. The problem is this
1) We make each customer register their account with us.
3) We do want multiple terminal services logins on one server to have to register each account with us.
3) We do NOT want multiple logins on one computer to have to register each account with us.
So, the problem arises in determining if a user is acting within a terminal services environment or not. So...how do I figure that out?
I know of an ugly hack that should work well. It's comparing what is returned from 2 different API calls. GetWindowsDirectory and GetSystemWindowsDirectory.
On a terminal services environment, GetWindowsDirectory would return something like C:\Documents and Settings\[username]\Windows\. And GetSystemWindowsDirectory would return C:\Windows.
On a multiple login environment (such as one computer that has multiple logins, but not through terminal services), GetWindowsDirectory and GetSystemWindowsDirectory would both return C:\Windows.
I don't like this fix too well. It should work, but it's more of a hack than a true solution. So is there a nice API call I can make to see if I'm truly in a terminal services environment?