public static bool LogOffSession(Session Session, bool Wait) { System.IntPtr server = WTSOpenServer(Session.ServerName); if (server != System.IntPtr.Zero) { return(TerminalServicesAPI.WTSLogoffSession(server, Session.SessionID, Wait)); } return(false); }
public static bool SendMessage(Session Session, string Title, string Message, int Style, int Timeout, bool Wait) { System.IntPtr server = WTSOpenServer(Session.ServerName); if (server != System.IntPtr.Zero) { int respose = 0; return(TerminalServicesAPI.WTSSendMessage(server, Session.SessionID, Title, Title.Length, Message, Message.Length, Style, Timeout, out respose, Wait)); } return(false); }
public static void ShutdownSystem(TerminalServer Server, bool Reboot) { long action = WTS_WSD_REBOOT; if (!Reboot) { action = WTS_WSD_SHUTDOWN; } System.IntPtr server = WTSOpenServer(Server.ServerName); if (server != System.IntPtr.Zero) { TerminalServicesAPI.WTSShutdownSystem(server, action); } }
public static void SendMessageToSession(Session session) { if (session != null) { string prompt = Resources.Pleaseenterthemessagetosend; InputBoxResult result = InputBox.Show(prompt, "Send network message"); if (result.ReturnCode == DialogResult.OK && !string.IsNullOrEmpty(result.Text)) { string meessageText = result.Text.Trim(); string messageHeader = Resources.MessagefromyourAdministrator; TerminalServicesAPI.SendMessage(session, messageHeader, meessageText, 0, 10, false); } } }
public static TerminalServer LoadServer(string ServerName) { return(TerminalServicesAPI.GetSessions(ServerName)); }