Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Terminal Server in Windows 2000
Message
De
19/04/2001 15:12:01
 
 
À
19/04/2001 09:42:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00497234
Message ID:
00497516
Vues:
10
>Hi.
>Does anybody tell me how can I separate different users who are running software via Terminal Server? When using SYS(0) function there is only machine name and user. But if there are users logged in with the same username.
>
>Thank you for the help,
>
>Tapani Korhonen

Hi Tapani,

You may use Terminal Services API to retrieve information about current session and user, it may be user network address, the name of the client (computer name), the name of the current session or the session ID. Here are some examples:
*-- WTS_INFO_CLASS enum
#define	WTSInitialProgram		0
#define	WTSApplicationName		1
#define	WTSWorkingDirectory		2
#define	WTSOEMId			3
#define	WTSSessionId			4
#define	WTSUserName			5
#define	WTSWinStationName		6
#define	WTSDomainName			7
#define	WTSConnectState			8
#define	WTSClientBuildNumber		9
#define	WTSClientName			10
#define	WTSClientDirectory		11
#define	WTSClientProductId		12
#define	WTSClientHardwareId		13
#define	WTSClientAddress		14
#define	WTSClientDisplay		15
#define	WTSClientProtocolType		16

#define WTS_CURRENT_SERVER_HANDLE	0
#define WTS_CURRENT_SESSION		-1


<I STYLE="COLOR:gray">*-- Retrieve the Name of the Client (client Computer name)</I>
?WTSSessionInfo( WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientName)

<I STYLE="COLOR:gray">*-- Retrieve the Current Session Name</I>
?WTSSessionInfo( WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSWinStationName)

... and so on


Function WTSSessionInfo( srvHandle, sessID, infID)
    Declare Integer WTSQuerySessionInformation In WTSAPI32 ;
        Integer hServer, ;
        Integer SessionID, ;
        Integer WTSInfoClass, ;
        Integer @ppBuffer, ;
        Integer @pBytesReturned

    Declare Long WTSFreeMemory In WTSAPI32 ;
        Integer pMemory

    Declare Integer RtlMoveMemory In Win32API ;
        String @outBuffer, ;
        Integer inBuffer, ;
        Integer bytesToMove

    lcBuffer = Repl( Chr(0), 1024)
    lnReturned = 0
    lnBufferPtr = 0

    If WTSQuerySessionInformation( m.srvHandle, m.sessID, m.infID, @m.lnBufferPtr, @m.lnReturned) = 0
        Return ""
    EndIf

    RtlMoveMemory( @m.lcBuffer, m.lnBufferPtr, m.lnReturned)

    WTSFreeMemory( m.lnBufferPtr)

    Return Left( m.lcBuffer, m.lnReturned)
EndFunc
Hope this helps.
Alex
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform