dim $decip[5]
$sid = InputBox("Pleaes enter SID!","-1 = Current Session")
$ip = Call("_GetWTSClientIP",$sid)
if Not @error then
MsgBox(0,"IP",$ip)
EndIf
Func _GetWTSClientIP($sid)
; http://msdn.microsoft.com/en-us/library/aa383838(v=VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa383857(v=VS.85).aspx
; BOOL WTSQuerySessionInformation(
; __in HANDLE hServer, ( 0 = Current)
; __in DWORD SessionId, (-1 = Current)
; __in WTS_INFO_CLASS WTSInfoClass,
; __out LPTSTR *ppBuffer,
; __out DWORD *pBytesReturned
; );
Local $result = DllCall("Wtsapi32.dll","int", "WTSQuerySessionInformationW", "Ptr", 0, "int", $sid, "int", 14, "ptr*", 0, "dword*", 0)
If @error Or $result[0] = 0 Then Return SetError(1,0,"")
Local $ip = DllStructGetData(DllStructCreate("byte[" & $result[5] & "]" , $result[4]),1)
DllCall("Wtsapi32.dll", "int", "WTSFreeMemory", "ptr", $result[4])
; Byte 2 IP
$ip = StringTrimLeft($ip,14)
$decip[1] = Dec(StringLeft($ip,2))
$ip = StringTrimLeft($ip,2)
$decip[2] = Dec(StringLeft($ip,2))
$ip = StringTrimLeft($ip,2)
$decip[3] = Dec(StringLeft($ip,2))
$ip = StringTrimLeft($ip,2)
$decip[4] = Dec(StringLeft($ip,2))
$ip = $decip[1] & "." & $decip[2] & "." & $decip[3] & "." & $decip[4]
Return $ip
EndFunc