Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Operating System Check
Message
De
03/09/2002 04:11:17
 
 
À
02/09/2002 18:34:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00695929
Message ID:
00696125
Vues:
14
>Thanks, but this still returns the operating system of the machine the app is running on. What if I need to check the operating system on another machine (i.e. the workstation logged on to the Citrix session)?

To query info about the wts session, use the WTSQuerySessionInformation api in WTSAPI32. The WTSClientProductId may return some info regarding the op system used by the client. Alternatively, you could use the machine address and try to derive the OS using that.

There is some sample code below. These functions are used in an environment where UDFPARMS are set to reference, but you can adapt them.

Mace


************************************************************
* A new func to return whether the session is a client of terminal services
*************************************************************
PROCEDURE IsTerminalService
LPARAMETERS tlIsTerminalService

DECLARE INTEGER GetSystemMetrics IN User32.dll INTEGER

tlIsTerminalService = ( GetSystemMetrics( 4096) > 0)

CLEAR DLLS

RETURN 0

************************************************************************************************************
* Returns a client service machine name
*
***********************************************************************************************************
PROCEDURE GETWTSClientName
LPARAMETERS tcSessionName
LOCAL lcBuffer, lnReturned, lnBufferPtr

*-- #defines, I listed these for doc purposes only, not all are used
*-- 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

*-- Declare the DLL's
DECLARE INTEGER WTSQuerySessionInformation In WTSAPI32 ;
INTEGER, ;
INTEGER, ;
INTEGER, ;
INTEGER @, ;
INTEGER @

DECLARE LONG WTSFreeMemory In WTSAPI32 INTEGER

DECLARE INTEGER RtlMoveMemory In Win32API ;
STRING @, ;
INTEGER, ;
INTEGER

lcBuffer = REPL( CHR(0), 1024)
lnReturned = 0
lnBufferPtr = 0

IF WTSQuerySessionInformation( 0, -1, 6, @lnBufferPtr, @lnReturned) = 0

DECLARE INTEGER GetLastError IN Win32API

lnError = GetLastError()

RETURN _ValidError
ENDIF

RtlMoveMemory( @lcBuffer, lnBufferPtr, lnReturned)

WTSFreeMemory( lnBufferPtr)

CLEAR DLLS

tcSessionName = LEFT( lcBuffer, lnReturned - 1)

RETURN 0
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform