コード例 #1
0
        public static EndPoint QuerySessionInformationForEndPoint(ITerminalServerHandle server, int sessionId)
        {
            int retLen;
            var remoteAddress = new WINSTATIONREMOTEADDRESS();

            if (
                NativeMethods.WinStationQueryInformationRemoteAddress(server.Handle, sessionId,
                                                                      WINSTATIONINFOCLASS.WinStationRemoteAddress,
                                                                      ref remoteAddress,
                                                                      Marshal.SizeOf(typeof(WINSTATIONREMOTEADDRESS)),
                                                                      out retLen) != 0)
            {
                var ipAddress = ExtractIPAddress(remoteAddress.Family, remoteAddress.Address);
                int port      = NativeMethods.ntohs((ushort)remoteAddress.Port);
                return(ipAddress == null ? null : new IPEndPoint(ipAddress, port));
            }
            throw new Win32Exception();
        }
コード例 #2
0
ファイル: NativeMethods.cs プロジェクト: dbremner/cassia
 public static extern int WinStationQueryInformationRemoteAddress(IntPtr hServer, int sessionId,
     WINSTATIONINFOCLASS information,
     ref WINSTATIONREMOTEADDRESS buffer,
     int bufferLength, out int returnedLength);
コード例 #3
0
 public static extern int WinStationQueryInformationRemoteAddress(IntPtr hServer, int sessionId,
                                                                  WINSTATIONINFOCLASS information,
                                                                  ref WINSTATIONREMOTEADDRESS buffer,
                                                                  int bufferLength, out int returnedLength);