コード例 #1
0
        /// <summary>
        /// Gets the sessions on the terminal server.
        /// </summary>
        /// <returns>An array of sessions.</returns>
        public TerminalServerSession[] GetSessions()
        {
            IntPtr dataPtr;
            int    count;

            TerminalServerSession[] sessions;

            if (!Win32.WTSEnumerateSessions(this, 0, 1, out dataPtr, out count))
            {
                Win32.ThrowLastError();
            }

            using (var data = new WtsMemoryAlloc(dataPtr))
            {
                sessions = new TerminalServerSession[count];

                for (int i = 0; i < count; i++)
                {
                    var session = data.ReadStruct <WtsSessionInfo>(i);
                    sessions[i] = new TerminalServerSession(
                        this,
                        session.SessionID,
                        session.WinStationName,
                        session.State
                        );
                }

                return(sessions);
            }
        }
コード例 #2
0
        public SessionInformationWindow(TerminalServerSession session)
        {
            InitializeComponent();
            this.AddEscapeToClose();
            this.SetTopMost();

            labelUsername.Text = session.DomainName + "\\" + session.UserName;
            labelSessionId.Text = session.SessionId.ToString();
            labelState.Text = session.State.ToString();

            if (!string.IsNullOrEmpty(session.ClientName))
                labelClientName.Text = session.ClientName;
            if (session.ClientAddress != null)
                labelClientAddress.Text = session.ClientAddress.ToString();
            if (session.ClientDisplay.ColorDepth != 0 && 
                session.ClientDisplay.ColorDepth != 2) // HACK
                labelClientDisplayResolution.Text =
                    session.ClientDisplay.HorizontalResolution + "x" +
                    session.ClientDisplay.VerticalResolution + "@" +
                    session.ClientDisplay.ColorDepth;
        }
コード例 #3
0
        /// <summary>
        /// Gets the sessions on the terminal server.
        /// </summary>
        /// <returns>An array of sessions.</returns>
        public TerminalServerSession[] GetSessions()
        {
            IntPtr dataPtr;
            int count;

            if (!Win32.WTSEnumerateSessions(this, 0, 1, out dataPtr, out count))
                Win32.Throw();

            using (WtsMemoryAlloc data = new WtsMemoryAlloc(dataPtr))
            {
                TerminalServerSession[] sessions = new TerminalServerSession[count];

                for (int i = 0; i < count; i++)
                {
                    WtsSessionInfo session = data.ReadStruct<WtsSessionInfo>(0, WtsSessionInfo.SizeOf, i);
                    
                    sessions[i] = new TerminalServerSession(
                        this,
                        session.SessionID,
                        session.WinStationName,
                        session.State
                        );
                }

                return sessions;
            }
        }