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); } }
public TerminalServer(string name) { _name = name; using (WtsServerCookie cookie = OpenServer()) { System.Diagnostics.Debug.Assert(cookie.Handle != IntPtr.Zero); } }
public void Logoff(Boolean wait) { using (WtsServerCookie cookie = _server.OpenServer()) { if (!NativeMethods.WTSLogoffSession(cookie.Handle, _sessionId, wait)) { throw PscxException.LastWin32Exception(); } } }
public void Shutdown(WtsShutdownType type) { using (WtsServerCookie cookie = OpenServer()) { if (!NativeMethods.WTSShutdownSystem(cookie.Handle, (int)(type))) { throw PscxException.LastWin32Exception(); } } }
public void TerminateProcess(int processId, int exitCode) { using (WtsServerCookie cookie = OpenServer()) { if (!NativeMethods.WTSTerminateProcess(cookie.Handle, processId, exitCode)) { throw PscxException.LastWin32Exception(); } } }