Exemplo n.º 1
0
        private void btnSystemInfo_Click(object sender, System.EventArgs e)
        {
            string wininfoexe     = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), @"Microsoft Shared\MSInfo\msinfo32.exe");         //C:\Program Files\Common Files\
            string consoleinfoexe = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "SystemInfo.exe");

            if (System.IO.File.Exists(wininfoexe))
            {
                Process.Start(wininfoexe);
            }
            else if (System.IO.File.Exists(consoleinfoexe))
            {
                ProcessStartInfo psi = new ProcessStartInfo(consoleinfoexe);
                psi.CreateNoWindow         = true;
                psi.ErrorDialog            = false;
                psi.RedirectStandardError  = false;
                psi.RedirectStandardOutput = true;
                psi.WindowStyle            = ProcessWindowStyle.Hidden;
                psi.WorkingDirectory       = Environment.GetFolderPath(Environment.SpecialFolder.System);
                psi.UseShellExecute        = false;

                Process proc = System.Diagnostics.Process.Start(psi);
                string  text = proc.StandardOutput.ReadToEnd();
                ShowText.Show(this, text);
            }
            else
            {
                MessageBox.Show("System Information can not be displayed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        /// <summary>Show a messagebox showing the specified exception.</summary>
        /// <remarks>Uses <see cref="ShowText"/> to display the exception text and stacktrace information</remarks>
        public static void ExceptionMessageBox(Form parentform, Exception ex)
        {
            string        stackTrace = ex.StackTrace;
            StringBuilder sb         = new StringBuilder("Exception thrown:");

            do
            {
                sb.Append(Environment.NewLine);
                sb.Append(ex.Message);
                ex = ex.InnerException;
            } while (ex != null);
            sb.Append(Environment.NewLine);
            sb.Append(stackTrace);
            sb.Replace("\x0D", "");                  // Remove all CR chars
            sb.Replace("\x0A", Environment.NewLine); // Replace all LF chars with the NewLine string.
            ShowText.Show(parentform, sb.ToString(), parentform == null ? "Exception" : parentform.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Exemplo n.º 3
0
 public static void ShowMessage(string s, string caption)
 {
     ShowText.Show(s, caption);
 }
Exemplo n.º 4
0
 public static void ShowMessage(string s)
 {
     ShowText.Show(s);
 }