This Function gets the Hostname of the Client on the Terminal Server,
can be used to determine the correct std printer near the location of the client while working on the terminal server session.
Func _GetWTSClientName($sid)
Local $result = DllCall("Wtsapi32.dll", "int", "WTSQuerySessionInformation", "Ptr", 0, "int", $sid, "int", 10, "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])
Return StringReplace(BinaryToString($ip), Chr(0), "")
EndFunc ;==>_GetWTSClientName
Best regards,
J