Get IP Address of Computer running an application through Terminal Services
Posted on 2006-11-01
What I want to do is get the ip address of a thin client that is running an application through terminal services on a server. I am using vb.net... I used
Dim ipE As IPHostEntry = Dns.GetHostEntry(sHOstName)
but this retrieves the ip address of the terminal server, and not the client. We have a vb6 application that successfully gets the ip of the client, and that code is posted below. The problem I have is that I don't know how to acheive this same thing in vb.net THIS IS URGENT! LOTS OF POINTS!
Here is the vb6 code that accomplishes what we want to accomplish
Public Function GetWTSQueryAddress() As String
Dim RetVal As Long, lpBuffer As Long, count As Long
Dim p As Long, i As Integer
Dim uName As String
' Dim WTSQueryInfo() As WTS_SESSION_QUERY
Dim WTSQueryAddress As WTS_CLIENT_ADDRESS
Dim SesID As Long
'SesID = GetWTSSessionID
RetVal = WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, _
WTS_CURRENT_SESSION, WTSClientAddress, lpBuffer, count)
If RetVal Then
p = lpBuffer
CopyMemory WTSQueryAddress, ByVal p, LenB(WTSQueryAddress)
uName = ""
For i = 2 To 5
uName = uName & WTSQueryAddress.address(i)
If i < 5 Then uName = uName & "."
'MsgBox "An error occurred calling WTSQuerySessionInformation. "
uName = ""
GetWTSQueryAddress = uName