*--------------------------------------------------------------------------- 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 *---------------------------------------------------------------------------