我想在C#按钮点击关闭运行exe ..但是我得到了
进程已退出,因此无法获取所请求的信息。
我的代码:
Process nynprocess = new Process();
private void button2_Click(object sender, EventArgs e)
{
string str = @"C:\Program Files\ShareX\ShareX";
nynprocess.StartInfo.FileName = str;
nynprocess.Start();
}
private void button3_Click(object sender, EventArgs e)
{
nynprocess.CloseMainWindow();
nynprocess.Kill();
nynprocess.WaitForExit();
}
答案 0 :(得分:0)
尝试使用此
// Close process by sending a close message to its main window.
nynprocess.CloseMainWindow();
// Free resources associated with process.
nynprocess.Close();