/// <summary> /// Displays a message box in the session and returns the user's response to the message box. /// </summary> /// <param name="text">The text to display in the message box.</param> /// <param name="caption">The caption of the message box.</param> /// <param name="synchronous">true to wait for and return the user's response to the message box. Otherwise, return immediately.</param> /// <param name="timeoutSeconds">The amount of time to wait for a response from the user before closing the message box. The system will wait forever if this is set to 0.</param> /// <param name="buttons">The buttons to display in the message box.</param> /// <param name="icon">The icon to display in the message box.</param> /// <param name="defaultButton">The button that should be selected by default in the message box.</param> /// <param name="options">Options for the message box.</param> /// <returns> /// The user's response to the message box. If <paramref name="synchronous" /> is <c>false</c>, the method will always return <see cref="RemoteMessageBoxResult.Asynchronous" />. /// If the timeout expired before the user responded to the message box, the result will be <see cref="RemoteMessageBoxResult.Timeout" />. /// </returns> public RemoteMessageBoxResult MessageBox( string text, string caption = null, bool synchronous = false, int timeoutSeconds = 0, RemoteMessageBoxButtons buttons = RemoteMessageBoxButtons.Ok, RemoteMessageBoxIcon icon = RemoteMessageBoxIcon.None, RemoteMessageBoxDefaultButton defaultButton = RemoteMessageBoxDefaultButton.Button1, RemoteMessageBoxOptions options = RemoteMessageBoxOptions.None& RemoteMessageBoxOptions.TopMost) { timeoutSeconds = timeoutSeconds < 0 ? 0 : timeoutSeconds; var style = (int)buttons | (int)icon | (int)defaultButton | (int)options; var result = NativeMethodsHelper.SendMessage( this._server.Handle, this._sessionId, caption, text, style, timeoutSeconds, synchronous); return(result == 0 ? RemoteMessageBoxResult.Timeout : result); }
private static void AskQuestion(string[] args) { if (args.Length < 8) { Console.WriteLine( "Usage: SessionInfo ask [server] [session id] [icon] [caption] [text] [timeout] [buttons]"); return; } int seconds = int.Parse(args[6]); int sessionId = int.Parse(args[2]); using (ITerminalServer server = GetServerFromName(args[1])) { server.Open(); ITerminalServicesSession session = server.GetSession(sessionId); RemoteMessageBoxIcon icon = (RemoteMessageBoxIcon)Enum.Parse(typeof(RemoteMessageBoxIcon), args[3], true); RemoteMessageBoxButtons buttons = (RemoteMessageBoxButtons)Enum.Parse(typeof(RemoteMessageBoxButtons), args[7], true); RemoteMessageBoxResult result = session.MessageBox(args[5], args[4], buttons, icon, default(RemoteMessageBoxDefaultButton), default(RemoteMessageBoxOptions), TimeSpan.FromSeconds(seconds), true); Console.WriteLine("Response: " + result); } }
public MessageBoxShower(RemoteDesktopTestService service, int sessionId, ConnectionDetails connection, string title, string text, RemoteMessageBoxButtons buttons, TimeSpan timeout) { _service = service; _sessionId = sessionId; _connection = connection; _title = title; _text = text; _buttons = buttons; _timeout = timeout; }
public RemoteMessageBoxResult MessageBox(string text, string caption, RemoteMessageBoxButtons buttons, RemoteMessageBoxIcon icon, RemoteMessageBoxDefaultButton defaultButton, RemoteMessageBoxOptions options, TimeSpan timeout, bool synchronous) { var timeoutSeconds = (int)timeout.TotalSeconds; var style = (int)buttons | (int)icon | (int)defaultButton | (int)options; // TODO: Win 2003 Server doesn't start timeout counter until user moves mouse in session. var result = NativeMethodsHelper.SendMessage(_server.Handle, _sessionId, caption, text, style, timeoutSeconds, synchronous); // TODO: Windows Server 2008 R2 beta returns 0 if the timeout expires. // find out why this happens or file a bug report. return(result == 0 ? RemoteMessageBoxResult.Timeout : result); }
public MessageBoxShower(RemoteDesktopTestService service, int sessionId, ConnectionDetails connection, string title, string text, RemoteMessageBoxButtons buttons, TimeSpan timeout) { _service = service; _sessionId = sessionId; _connection = connection; _title = title; _text = text; _buttons = buttons; _timeout = timeout; }
public void StartShowingMessageBox(ConnectionDetails connection, int sessionId, string windowTitle, string text, RemoteMessageBoxButtons buttons, TimeSpan timeout) { new MessageBoxShower(this, sessionId, connection, windowTitle, text, buttons, timeout).Show(); }
public RemoteMessageBoxResult MessageBox(string text, string caption, RemoteMessageBoxButtons buttons, RemoteMessageBoxIcon icon, RemoteMessageBoxDefaultButton defaultButton, RemoteMessageBoxOptions options, TimeSpan timeout, bool synchronous) { var timeoutSeconds = (int) timeout.TotalSeconds; var style = (int) buttons | (int) icon | (int) defaultButton | (int) options; // TODO: Win 2003 Server doesn't start timeout counter until user moves mouse in session. var result = NativeMethodsHelper.SendMessage(_server.Handle, _sessionId, caption, text, style, timeoutSeconds, synchronous); // TODO: Windows Server 2008 R2 beta returns 0 if the timeout expires. // find out why this happens or file a bug report. return result == 0 ? RemoteMessageBoxResult.Timeout : result; }
public void StartShowingMessageBox(ConnectionDetails connection, int sessionId, string windowTitle, string text, RemoteMessageBoxButtons buttons, TimeSpan timeout) { new MessageBoxShower(this, sessionId, connection, windowTitle, text, buttons, timeout).Show(); }