Detecting If User Is In Remote Desktop Mode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SqUiMbO
    New Member
    • Feb 2007
    • 5

    Detecting If User Is In Remote Desktop Mode

    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!
  • SqUiMbO
    New Member
    • Feb 2007
    • 5

    #2
    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.

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      Have you looked through the System.Security Namespace?

      Comment

      • SqUiMbO
        New Member
        • Feb 2007
        • 5

        #4
        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

        • RedSon
          Recognized Expert Expert
          • Jan 2007
          • 4980

          #5
          Great I'm interested to see how it turns out!

          Comment

          • SqUiMbO
            New Member
            • Feb 2007
            • 5

            #6
            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

            • RedSon
              Recognized Expert Expert
              • Jan 2007
              • 4980

              #7
              If the use is authenticated through the windows operating system it will have a unified security context for you to query based on that users GUID/SECUID, so no worries there :)

              Comment

              • jaks13579
                New Member
                • Jan 2008
                • 1

                #8
                I only know vb6, could someone perhaps send me a copy of a working compiled version of this code that I could some how integrate into a vb6 app?

                deleted

                Thanks.
                Last edited by RedSon; Jan 11 '08, 03:55 PM.

                Comment

                • RedSon
                  Recognized Expert Expert
                  • Jan 2007
                  • 4980

                  #9
                  Originally posted by jaks13579
                  I only know vb6, could someone perhaps send me a copy of a working compiled version of this code that I could some how integrate into a vb6 app?

                  deleted

                  Thanks.
                  No .

                  Comment

                  Working...