我有以下結構:開箱_WTS_CLIENT_ADDRESS.Address在vb.net(從終端服務客戶端獲取IP地址)
<StructLayout(LayoutKind.Sequential)> _
Public Structure _WTS_CLIENT_ADDRESS
Public AddressFamily As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)> _
Public Address() As Byte
End Structure
這是由以下調用填充:
Dim _ClientIPAddress As New _WTS_CLIENT_ADDRESS
Dim rtnPtr As IntPtr
Dim rtncount As Int32
NativeMethods.WTSQuerySessionInformation(CInt(NativeMethods.WTS_CURRENT_SERVER_HANDLE), NativeMethods.WTS_CURRENT_SESSION, NativeMethods.WTS_INFO_CLASS.WTSClientAddress, rtnPtr, rtncount)
'_ClientIPAddress()
_ClientIPAddress = _
CType(System.Runtime.InteropServices.Marshal.PtrToStructure(rtnPtr, GetType(_WTS_CLIENT_ADDRESS)), _WTS_CLIENT_ADDRESS)
地址字節數組正在填充,但我不知道如何將其轉換爲有用的字符串或整數值。 MDSN文檔很稀少:http://msdn.microsoft.com/en-us/library/aa383857(VS.85).aspx