Ejemplo n.º 1
0
        internal TerminalSessionCollection(TerminalServer server)
            : base(new System.Collections.Generic.List <TerminalSession>())
        {
            int    count = 0;
            IntPtr ptr   = IntPtr.Zero;

            using (WtsServerCookie cookie = server.OpenServer())
            {
                if (!NativeMethods.WTSEnumerateSessions(cookie.Handle, 0, 1, out ptr, out count))
                {
                    throw PscxException.LastWin32Exception();
                }
            }

            try
            {
                foreach (WTS_SESSION_INFO info in Utils.ReadNativeArray <WTS_SESSION_INFO>(ptr, count))
                {
                    Items.Add(new TerminalSession(server, info));
                }
            }
            finally
            {
                NativeMethods.WTSFreeMemory(ptr);
            }
        }
Ejemplo n.º 2
0
        internal TerminalSession(TerminalServer server, WTS_SESSION_INFO info)
        {
            _server     = server;
            _sessionId  = info.SessionId;
            _winStation = info.WinStationName;
            _state      = (TerminalSessionState)(info.State);

            _client = new TerminalSessionClientInfo(this);
        }