/// <summary>
        /// Initializes a new instance of the <see cref="TerminalServicesSession" /> class.
        /// </summary>
        /// <param name="server">TerminalServer instance.</param>
        /// <param name="sessionId">Session Id.</param>
        internal TerminalServicesSession(TerminalServer server, int sessionId)
        {
            this._server    = server;
            this._sessionId = sessionId;

            this._clientBuildNumber  = new LazyLoadedProperty <int>(this.GetClientBuildNumber);
            this._clientIPAddress    = new LazyLoadedProperty <IPAddress>(this.GetClientIPAddress);
            this._remoteEndPoint     = new LazyLoadedProperty <EndPoint>(this.GetRemoteEndPoint);
            this._clientDisplay      = new LazyLoadedProperty <ClientDisplay>(this.GetClientDisplay);
            this._clientDirectory    = new LazyLoadedProperty <string>(this.GetClientDirectory);
            this._workingDirectory   = new LazyLoadedProperty <string>(this.GetWorkingDirectory);
            this._initialProgram     = new LazyLoadedProperty <string>(this.GetInitialProgram);
            this._applicationName    = new LazyLoadedProperty <string>(this.GetApplicationName);
            this._clientHardwareId   = new LazyLoadedProperty <int>(this.GetClientHardwareId);
            this._clientProductId    = new LazyLoadedProperty <short>(this.GetClientProductId);
            this._clientProtocolType = new LazyLoadedProperty <ClientProtocolType>(this.GetClientProtocolType);
            this._clientName         = new LazyLoadedProperty <string>(this.GetClientName);

            var loader = IsVistaSp1OrHigher ? (GroupPropertyLoader)this.LoadWtsInfoProperties : this.LoadWinStationInformationProperties;

            this._windowStationName  = new GroupLazyLoadedProperty <string>(loader);
            this._connectState       = new GroupLazyLoadedProperty <ConnectState>(loader);
            this._connectTime        = new GroupLazyLoadedProperty <DateTime?>(loader);
            this._currentTime        = new GroupLazyLoadedProperty <DateTime?>(loader);
            this._disconnectTime     = new GroupLazyLoadedProperty <DateTime?>(loader);
            this._lastInputTime      = new GroupLazyLoadedProperty <DateTime?>(loader);
            this._loginTime          = new GroupLazyLoadedProperty <DateTime?>(loader);
            this._userName           = new GroupLazyLoadedProperty <string>(loader);
            this._domainName         = new GroupLazyLoadedProperty <string>(loader);
            this._incomingStatistics = new GroupLazyLoadedProperty <ProtocolStatistics>(loader);
            this._outgoingStatistics = new GroupLazyLoadedProperty <ProtocolStatistics>(loader);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TerminalServicesProcess" /> class.
        /// </summary>
        /// <param name="server">TerminalServer instance.</param>
        /// <param name="processInfo">WTS_PROCESS_INFO instance.</param>
        internal TerminalServicesProcess(TerminalServer server, WTS_PROCESS_INFO processInfo)
        {
            this._server      = server;
            this._sessionId   = processInfo.SessionId;
            this._processId   = processInfo.ProcessId;
            this._processName = processInfo.ProcessName;

            if (processInfo.UserSid != IntPtr.Zero)
            {
                this._securityIdentifier = new SecurityIdentifier(processInfo.UserSid);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TerminalServicesSession" /> class.
 /// </summary>
 /// <param name="server">TerminalServer instance.</param>
 /// <param name="sessionInfo">WTS_SESSION_INFO instance.</param>
 internal TerminalServicesSession(TerminalServer server, WTS_SESSION_INFO sessionInfo)
     : this(server, sessionInfo.SessionID)
 {
     this._windowStationName.Value = sessionInfo.WinStationName;
     this._connectState.Value      = sessionInfo.ConnectState;
 }