Ejemplo n.º 1
0
 public void Disconnect(Boolean wait)
 {
     using (WtsServerCookie cookie = _server.OpenServer())
     {
         if (!NativeMethods.WTSDisconnectSession(cookie.Handle, _sessionId, wait))
         {
             throw PscxException.LastWin32Exception();
         }
     }
 }
Ejemplo n.º 2
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);
            }
        }