Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:36:31+00:00 2026-06-10T20:36:31+00:00

I connect to my PC (Windows XP Pro, which runs 24/7) through RDP on

  • 0

I connect to my PC (Windows XP Pro, which runs 24/7) through RDP on an off through the day.
I have a background process that should do some things upon RDP connection, but I couldn’t figure a way to make it detect the establishing of the RDP connection.

No new processes are created, WTSQuerySessionInformation doesn’t help (I connect to the same eternal Windows session).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:36:32+00:00Added an answer on June 10, 2026 at 8:36 pm

    The answer is WTSRegisterSessionNotification() from wtsapi32.dll.

    This signs you up for receiving WM_WTSSESSION_CHANGE notifications, whose WParam could be WTS_REMOTE_CONNECT, WTS_REMOTE_DISCONNECT. That does it.

    Here is the simplest AutoIt implementation:

    #include <GUIConstantsEx.au3>
    #include <Date.au3>
    #include <WindowsConstants.au3>
    
    Global Const $hWTSAPI32 = DllOpen("wtsapi32.dll")
    Global $i = 0, $tTime
    
    _Main()
    
    Func _Main()
        Local $hGUI
        
        ; Create GUI
        $hGUI = GUICreate("Session change detection", 600, 400)
    ;~  GUISetState()  ; show the window
        
        DllCall($hWTSAPI32, "int", "WTSRegisterSessionNotification", "hwnd", $hGUI, "dword", 1) ; NOTIFY_FOR_ALL_SESSIONS
        If @error Then 
            MsgBox(0,"", "Error calling WTSRegisterSessionNotification()")
            Exit
        EndIf
        
        GUIRegisterMsg(0x2B1, "WTSSESSION_CHANGE")  ; WM_WTSSESSION_CHANGE <=====================
        
        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
       
    EndFunc   ;==>_Main
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Func WTSSESSION_CHANGE($hWndGUI, $MsgID, $WParam, $LParam)
        ; WTS_REMOTE_CONNECT = 0x3, WTS_REMOTE_DISCONNECT = 0x4
        ; WTS_SESSION_UNLOCK = 0x8, WTS_SESSION_LOGON = 0x5
        If $WParam = 3 Then
            $tTime = _Date_Time_GetSystemTime()
            MsgBox(0, "Caught a notification", "Remote session connected at " & _Date_Time_SystemTimeToDateTimeStr($tTime) )
            Exit
        EndIf
    EndFunc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've got an XP Pro workstation that is reporting Windows cannot connect to
How do I write code to connect through Windows VPN client? I want this
I'm creating a windows service that will let different users connect to the PC
I have SQL Server 2000 and 2008 installed on a Windows XP Pro box.
I have a virtual machine on a remote computer, to which I connect using
i have a virtual ubuntu server running in windows 7 pro using VMware Player.
Having a weird issue. I'm new to Macs and have a windows VM that
I have an application which I have managed to keep reasonably cross-platform between windows
I am running MAC with parallels installed. I have windows 7 Pro installed on
I have a windows mobile 6.5 device which is not being detected by the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.