Is my app being used by RDP ?

Is my app being used by RDP ?

Postby Antonio Linares » Tue Apr 12, 2022 4:18 pm

Here you have a FWH example, please remember to link Wtsapi32.lib

Code: Select all  Expand view
#include "FiveWin.ch"

#define WM_WTSSESSION_CHANGE  0x02B1

#define WTS_CONSOLE_CONNECT    0x1  // The session identified by lParam was connected to the console terminal or RemoteFX session.
#define WTS_CONSOLE_DISCONNECT 0x2  // The session identified by lParam was disconnected from the console terminal or RemoteFX session.
#define WTS_REMOTE_CONNECT     0x3  // The session identified by lParam was connected to the remote terminal.
#define WTS_REMOTE_DISCONNECT  0x4  // The session identified by lParam was disconnected from the remote terminal.
#define WTS_SESSION_LOGON      0x5  // A user has logged on to the session identified by lParam.
#define WTS_SESSION_LOGOFF     0x6  // A user has logged off the session identified by lParam.
#define WTS_SESSION_LOCK       0x7  // The session identified by lParam has been locked.
#define WTS_SESSION_UNLOCK     0x8  // The session identified by lParam has been unlocked.
#define WTS_SESSION_REMOTE_CONTROL 0x9 // The session identified by lParam has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.
#define WTS_SESSION_CREATE     0xA  // Reserved for future use.
#define WTS_SESSION_TERMINATE  0xB  // Reserved for future use.

#define NOTIFY_FOR_ALL_SESSIONS   1
#define NOTIFY_FOR_THIS_SESSION   0

function Main()

   local oWnd := TMyWindow():New()

   WTSRegisterSessionNotification( oWnd:hWnd, NOTIFY_FOR_ALL_SESSIONS )

   ACTIVATE WINDOW oWnd VALID ( WTSUnRegisterSessionNotification( oWnd:hWnd ), .T. )

return nil

CLASS TMyWindow FROM TWindow

   METHOD HandleEvent( nMsg, nWParam, nLParam )

ENDCLASS

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow

   if nMsg == WM_WTSSESSION_CHANGE
      switch nWParam
         case WTS_CONSOLE_CONNECT
            MsgInfo( "WTS_CONSOLE_CONNECT", "console ID:" + AllTrim( Str( nLParam ) ) )

         case WTS_CONSOLE_DISCONNECT
            MsgInfo( "WTS_CONSOLE_DISCONNECT", "console ID:" + AllTrim( Str( nLParam ) ) )
      end
   endif

return ::Super:HandleEvent( nMsg, nWParam, nLParam )

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <wtsapi32.h>

HB_FUNC( WTSREGISTERSESSIONNOTIFICATION )
{
   hb_retl( WTSRegisterSessionNotification( ( HWND ) hb_parnll( 1 ), hb_parnl( 2 ) ) );
}

HB_FUNC( WTSUNREGISTERSESSIONNOTIFICATION )
{
   hb_retl( WTSUnRegisterSessionNotification( ( HWND ) hb_parnll( 1 ) ) );
}
#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Is my app being used by RDP ?

Postby Otto » Wed Apr 13, 2022 4:49 am

Dear Antonio,
I have compiled the program, and now I see an empty dialog.
Can you please describe briefly what the program does?
Is it installed on the server?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6043
Joined: Fri Oct 07, 2005 7:07 pm

Re: Is my app being used by RDP ?

Postby Antonio Linares » Wed Apr 13, 2022 6:43 am

Dear Otto,

You have to run your EXE remotely (on the server) using RDP, then it should MsgInfo() about it

Also it may be worth to try the Harbour function WIN_OSISTSCLIENT() --> lYesNo that should also behave in a similar way,
though the above solution is far more complete
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Is my app being used by RDP ?

Postby Otto » Wed Apr 13, 2022 8:31 am

Dear Antonio, Thank you for your answer.

I'm not sure I understand "running remotely" correctly.

I open a RDP session and then I start my program in the remote session.

Is that correct?

Now I have first started the exe with WTSRegisterSessionNotification- via Total Commander - and see the DIALOG window.

Then I start WINHOTEL.

Should I now get a MSGInfo.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6043
Joined: Fri Oct 07, 2005 7:07 pm

Re: Is my app being used by RDP ?

Postby Antonio Linares » Wed Apr 13, 2022 8:39 am

Dear Otto,

How are winhotel and the above example related ?

Have you modified winhotel using the above code ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41356
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Is my app being used by RDP ?

Postby Otto » Wed Apr 13, 2022 9:10 am

Dear Antonio,
No. I only started WINHOTEL as it is.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6043
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 35 guests