Hola Carlos
 
Espero que este procedimiento te sea de utilidad.
 
Saludos
 
José Paez
 
 
 
Local nSessionId, cClientName, ClientIpAddress
Try
= This.GetClientInfo(@nSessionId, @cClientName, @ClientIpAddress )
Messagebox( cClientName )
Catch To oEx
Endtry
 
*--------------------------------
Procedure GetClientInfo
Lparameters 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
 
Declare Integer WTSQuerySessionInformation In Wtsapi32.Dll ;
integer hServer, ;
integer SessionId, ;
Integer WTSInfoClass, ;
long @ ppBuffer, ;
integer @pBytesReturned
 
Declare WTSFreeMemory In Wtsapi32.Dll Long address
Local ClientAddress, nBytes, sts, i
ClientAddress = Repl( Chr(0), 4 + 20)
nBytes = 0
ppBuffer = 0
 
&& ClientIpAddress
sts = WTSQuerySessionInformation( ;
WTS_CURRENT_SERVER_HANDLE, ;
WTS_CURRENT_SESSION, ;
WTSClientAddress, ;
@ppBuffer, ;
@nBytes ;
)
ClientIpAddress = ''
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
 
&& SessionId
sts = WTSQuerySessionInformation( ;
WTS_CURRENT_SERVER_HANDLE, ;
WTS_CURRENT_SESSION, ;
WTSSessionId, ;
@ppBuffer, ;
@nBytes ;
)
SessionId = 0
Do Case
Case !Empty(sts)
Declare RtlMoveMemory In win32api Long @Dest, Long Src, Long BytesToCopy
=RtlMoveMemory( @SessionId , ppBuffer, 4)
=WTSFreeMemory( ppBuffer )
Endcase
 
&& ClientName
sts = WTSQuerySessionInformation( ;
WTS_CURRENT_SERVER_HANDLE, ;
WTS_CURRENT_SESSION, ;
WTSClientName, ;
@ppBuffer, ;
@nBytes ;
)
ClientName = Repl(Chr(0), 255)
Do Case
Case !Empty(sts)
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
Endproc
 



From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: [GUFA] terminal serviceDate: Mon, 
10 Nov 2008 15:21:39 -0200


Otra del terminal service,
alguien sabe si hay alguna manera de que la funcion SYS(0) te devuelva el nombre
de la terminal local desde donde se logueó y no el nombre del servidor ya que 
algunas cosas las armo de acuerdo al nombre de
la terminal ?
desde ya muchas gracias.
Carlos Morandin    
_________________________________________________________________
Stay up to date on your PC, the Web, and your mobile phone with Windows Live
http://clk.atdmt.com/MRT/go/119462413/direct/01/

Responder a