Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detect which terminal connected to Windows Terminal Serv
Message
De
16/08/2005 06:12:13
 
 
À
16/08/2005 05:14:54
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01041232
Message ID:
01041251
Vues:
25
>excellent... :))
>
>>If you mean, how do I know if my software is running on a terminal server, see message#790379
>>
>>I remember that sessionID is zero, if run on a console (normal screen) of any computer (including terminal server)
>>
>>If the SessionId is not zero, then you are running on a terminal server and not on the console of that terminal server (ie remote login)

hi Metin,

Just saw that for XP the sessionId can be 0 for a session that does not run on the console

Maybe it is safer to test the ClientName, clientaddress, ..
see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/termserv/wtsquerysessioninformation.asp
*---------------------------------------------------------------------------
function do_it()

	?'Am I on TS : ', !empty(TSClientName())
endfunc
*---------------------------------------------------------------------------
#ifndef WTS_CURRENT_SERVER_HANDLE
	#define WTS_CURRENT_SERVER_HANDLE (0) 
	#define WTS_CURRENT_SESSION   (-1) 


	#define WTSSessionId    (4) 
	#define WTSClientName    (10) 
	#define WTSClientAddress   (14) 

#endif

#ifndef AF_INET 
	#define AF_INET  2 
#endif 


function TSClientName()

	declare integer WTSQuerySessionInformation in Wtsapi32.dll ;
		integer hServer, ;
		integer SessionId, ;
		Integer WTSInfoClass, ;
		long @ ppBuffer, ;
		integer @pBytesReturned
	
	declare WTSFreeMemory in Wtsapi32.dll long address
	
	local sts, nBytes, ppbuffer, ClientName 
	nBytes = 0
	ppBuffer = 0

	&& ClientName
	sts = WTSQuerySessionInformation( ;
			WTS_CURRENT_SERVER_HANDLE, ;
			WTS_CURRENT_SESSION, ;
			WTSClientName, ;
			@ppBuffer, ;
			@nBytes ;
			)
	ClientName = repl(chr(0), 255)

	do case
	case !empty(sts) and !empty(ppBuffer)
		
		declare RtlMoveMemory in win32api string @Dest, long Src, long BytesToCopy
		=RtlMoveMemory( @ClientName, ppBuffer, nBytes )
		=WTSFreeMemory( ppBuffer )
		ClientName = left(ClientName, nBytes -1)

	otherwise
		ClientName = ''
	endcase

	return ClientName 
endfunc
*---------------------------------------------------------------------------
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform