????1. ???????????????????????
????2. ???????????????????
????3. ??????????????????????
????4. ??????????????????????????
// using System.Diagnostics;
private string appName = "calc.exe";
/// <summary>
/// 1. ???????????????????
/// </summary>
private void button1_Click(object sender?? EventArgs e)
{
Process.Start(appName);
MessageBox.Show(String.Format("?????? {0} ???????"?? this.appName)?? this.Text??
MessageBoxButtons.OK?? MessageBoxIcon.Information);
}
/// <summary>
/// 2. ?????????????????
/// </summary>
private void button2_Click(object sender?? EventArgs e)
{
try
{
Process proc = Process.Start(appName);
if (proc != null)
{
proc.WaitForExit(3000);
if (proc.HasExited) MessageBox.Show(String.Format("?????? {0} ????????"?? this.appName)?? this.Text??
MessageBoxButtons.OK?? MessageBoxIcon.Information);
else
{
// ???????????н??????????????????
proc.Kill();
MessageBox.Show(String.Format("?????? {0} ??????????"?? this.appName)?? this.Text?? MessageBoxButtons.OK?? MessageBoxIcon.Exclamation);
}
}
}
catch (ArgumentException ex)
{
MessageBox.Show(ex.Message?? this.Text?? MessageBoxButtons.OK?? MessageBoxIcon.Error);
}
}
/// <summary>