G
green
Hey there - I'm looking for a working solution to get the IP address of
a client that has connected into a terminal services server.
IE, the user would be logged into the server, and they would run an app
that would like to know the ip address that they're connecting from.
I really need the solution to work in a .NET app (VB).
I've seen the tons of sample code out there for
WTSQuerySessionInformation, but no matter what I do I can't seem to get
it to run in VB.NET....
In particular, when I run this code,
Dim joe As New System.IntPtr
Dim bytes As New UInteger
Dim pp As New WtsApi32.WtsClientAddress
Dim t As Boolean =
WtsApi32.NativeMethods.WtsQuerySessionInformation(0, -1,
WtsInfoClass.WtsClientAddress, joe, bytes)
pp = CType(Marshal.PtrToStructure(joe,
GetType(WtsApi32.WtsClientAddress)), WtsApi32.WtsClientAddress)
bla = pp.Address(2) & "." & pp.Address(3) & "." & pp.Address(4)
& "." & pp.Address
I get an error assigning PP, "AccessViolationException"
I'm using .NET 2.0 - is any of this found in native .NET code? If not,
can anyone help me out?
a client that has connected into a terminal services server.
IE, the user would be logged into the server, and they would run an app
that would like to know the ip address that they're connecting from.
I really need the solution to work in a .NET app (VB).
I've seen the tons of sample code out there for
WTSQuerySessionInformation, but no matter what I do I can't seem to get
it to run in VB.NET....
In particular, when I run this code,
Dim joe As New System.IntPtr
Dim bytes As New UInteger
Dim pp As New WtsApi32.WtsClientAddress
Dim t As Boolean =
WtsApi32.NativeMethods.WtsQuerySessionInformation(0, -1,
WtsInfoClass.WtsClientAddress, joe, bytes)
pp = CType(Marshal.PtrToStructure(joe,
GetType(WtsApi32.WtsClientAddress)), WtsApi32.WtsClientAddress)
bla = pp.Address(2) & "." & pp.Address(3) & "." & pp.Address(4)
& "." & pp.Address
I get an error assigning PP, "AccessViolationException"
I'm using .NET 2.0 - is any of this found in native .NET code? If not,
can anyone help me out?