Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine is application is running under Terminal Serve
Message
De
25/08/2004 09:54:38
 
 
À
25/08/2004 04:02:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00935468
Message ID:
00936287
Vues:
31
Thanks Gregory. That appears to work great! :o)

Tracy

>>Hi Tore,
>>
>>I decided to test this myself because we have an app that is sometimes run via terminal services. However, when I run it on my workstation as a test, it reports that my workstation is a terminal server. That is not the same thing as determining if an app is running from a terminal server and via terminal services. The app could be run outside of terminal services but on a computer that is also running terminal services. My computer is running terminal services too but I was not running the app via terminal services. I looked around MSFT's websites and couldn't locate anything else. Do you know of anymore links?
>>
>>Tracy
>>
>>
>>>Yes. Check out http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q251066
>>>
>>>>Is it possible to determine if an application has been started under Terminal Server.
>>>>
>>>>I have looked at the OS() function but I get the impression that it does not tell me that the application is actually running under Terminal Server.
>>>>I see that OS(10) can return that 'Terminal service is installed' and OS(11) can return that 'The system is a server' but I need to know if the running application is running under TS.
>>>>
>>>>Any suggestions are welcome.
>>>>
>>>>Thanks in advance,
>>>>
>>>>Ron Brahma
>_________________________________________________________________________________
>
>hi Tracy,
>
>
>GetClientInfo() will return FALSE if the libraries of TS are not installed (eg win 98).
>If it returns TRUE, then look for ClientName <> '' or ClientIpAddress <> ''
>
>[update, I first looked for SessionId > 0. This is not correct since SessionId = 0 is valid on XP]
>
>
>I'm not sure whether the ClientIpAddress is what it should be. I tested this on a TS of a customer and got 192.168.1.3 which is also what tsadmin is reporting. I thought that 192.168 referred to the internal network.
>
>For further info see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/termserv/wtsquerysessioninformation.asp
>
>Cases tested
>
>(1) On my pc, ClientName = '', ClientIpAddress = ''
>
>(2) logged in on a TS: SessionId > 0, ClientName = something, ClientIpAddress = something
>
>(3) from (2), NetOp to another computer on the LAN, ClientName = '', ClientIpAddress = ''
>
>So this may be what you are after
>
>
>
>local SessionId, ClientName, ClientIpAddress
>ExecutingOnTS = GetClientInfo(@SessionId, @ClientName, @ClientIpAddress ) and !empty(ClientIpAddress)
>
>
>
>
>*---------------------------------------------------------------------------
>function do_it()
>
>	local SessionId, ClientName, ClientIpAddress
>
>	?GetClientInfo(@SessionId, @ClientName, @ClientIpAddress )
>	?'SessionId: ', SessionId
>	?'ClientName: ', ClientName
>	?'ClientIpAddress: ', ClientIpAddress
>endfunc
>*--------------------------------------------------------------------------
>#IFNDEF	TRUE
>	#define	TRUE	.T.
>	#define	FALSE	.F.
>
>	#define	MAX_INTEGER	(0x7fffffff)
>#ENDIF
>
>function GetClientInfo(SessionId, ClientName, ClientIpAddress )
>
>#define WTS_CURRENT_SERVER_HANDLE	(0)
>#define WTS_CURRENT_SESSION			(-1)
>
>#define	WTSSessionId				(4)
>#define	WTSClientName				(10)
>#define WTSClientAddress			(14)
>
>#ifndef AF_INET
>#define AF_INET  2
>#endif
>
>	local Success
>	Success = TRUE
>	
>	local sError
>	sError = on('error')
>	on error Success = FALSE
>	
>	declare integer WTSQuerySessionInformation in Wtsapi32.dll ;
>		integer hServer, ;
>		integer SessionId, ;
>		Integer WTSInfoClass, ;
>		long @ ppBuffer, ;
>		integer @pBytesReturned
>
>	declare WTSFreeMemory in Wtsapi32.dll long address
>	on error &sError
>	
>	SessionId = 0
>	ClientName = ''
>	ClientIpAddress = ''
>	
>	local ClientAddress, nBytes, sts, i
>	ClientAddress = repl( chr(0), 4 + 20)
>	nBytes = 0
>	ppBuffer = 0
>
>	do case
>	case !Success
>	
>	otherwise
>		&& ClientIpAddress
>		sts = WTSQuerySessionInformation( ;
>				WTS_CURRENT_SERVER_HANDLE, ;
>				WTS_CURRENT_SESSION, ;
>				WTSClientAddress, ;
>				@ppBuffer, ;
>				@nBytes ;
>				)
>
>		do case
>		case !empty(sts)
>			declare RtlMoveMemory in win32api string @Dest, long Src, long BytesToCopy
>			=RtlMoveMemory( @ClientAddress, ppBuffer, nBytes)
>			=WTSFreeMemory( ppBuffer )
>
>			do case
>			case left(ClientAddress,1) == chr(AF_INET)
>				for i = 7 to 7+ 3
>					ClientIpAddress = ClientIpAddress  + iif(empty(ClientIpAddress), '', '.') + transform(asc(substr(ClientAddress, i, 1)))
>				endfor
>	 		endcase	
>	 			
>		endcase
>
>	endcase
>	
>	do case
>	case !Success
>	
>	otherwise
>		&& SessionId
>		sts = WTSQuerySessionInformation( ;
>				WTS_CURRENT_SERVER_HANDLE, ;
>				WTS_CURRENT_SESSION, ;
>				WTSSessionId, ;
>				@ppBuffer, ;
>				@nBytes ;
>				)
>		
>
>		do case
>		case !empty(sts)
>			declare RtlMoveMemory in win32api long @Dest, long Src, long BytesToCopy
>			=RtlMoveMemory( @SessionId , ppBuffer, 4)
>			=WTSFreeMemory( ppBuffer )
>		endcase
>
>	endcase
>
>	do case
>	case !Success
>	
>	otherwise
>		&& 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, len(ClientName))
>			=WTSFreeMemory( ppBuffer )
>			ClientName = left(ClientName, at(chr(0), ClientName)-1)
>
>		otherwise
>			ClientName = ''
>		endcase
>	endcase
>	
>	return Success
>
>endfunc
>*--------------------------------------------------------------------------
>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform