I have been searching and searching for a way to detect whether or not the user who launched my application is a local user or someone that is "remoted" in. This sounds like a very simple thing to check, but I cannot find any articles about it anywhere, nor could I find it in the Microsoft language reference. I know that is it possible, as, for example, Windows will not a "remote" user run a Direct3D app. It pops up a message saying something like "You cannot run Direct3D while in Remote Desktop" (I found this catchable error while playing around with XNA). However, this question is not about XNA! I am building a screensaver with VB 2005 (non-D3D) and I need to do this check, because on certain machines (servers) there will be several users logged in at one time and they do not want 10 screensaver instances to peg out the CPU needle. If the user is "remote", I am going to tell the screensaver to show a "dumbed-down" version (blank screen) to save precious CPU usage. I just need to know how to check for this!!! If you have any suggestions, work-arounds, or can just point me in the right direction, I would be greatful! THANKS!
Detecting If User Is In Remote Desktop Mode
Collapse
X
-
I guess I did not look "deep" enough or for the right thing. I found this post buried in thescripts discussions...
http://www.thescripts. com/forum/thread442528.ht ml
It only works on Windows Server though (which I luckily have). Now I just have to figure out how to get Flash installed on my Windows server, without the stupid info bar blocking my every move! LOL But that's not relevant to this topic...
If you have any other suggestions about detecting RDP (especially on a Windows XP machine), I would still love to hear them. -
SUCCESS!!! I think. Yes, I had previously looked through the System.Security namespace (mainly system.security .principal). It seems like there should have been an "isLocal" or "isRemote" property, but of course there is not. I got to looking deeper in the Object Browser and discovered this buried DEEP within the Windows.Forms ns.
Public Shared ReadOnly Property TerminalServerS ession() As Boolean
Member of: System.Windows. Forms.SystemInf ormation
Summary:
Gets a value indicating whether the calling process is associated with a Terminal Services client session.
Return Values:
true if the calling process is associated with a Terminal Services client session; otherwise, false.
It at least worked the first time I tried it. Returned "false" when ran locally (on XP) and returned "true" when I tried to run it remotely (also Windows XP). It needs a little more testing, but I think it is the correct thing to use for my purposes. I will post again after I give it a "good" testing!Comment
-
It seems to be working great for both XP and Windows Server 2003! At least with Remote Desktop Connection. I do not know how it will react with certain 3rd party terminal connection software, because I have none to try. I suppose a terminal connection is a terminal connection though.Comment
Comment