好的,我还有另外一个,现在正在处理按钮,在代码中名为installbtn。
现在我已经在我的代码中了。
private void installbtn_Click(object sender, EventArgs e)
{
// Access the internal exe resource pcc - the pcc is Path Copy Copy, which i am using as a
// requirement to use this software
byte[] pccFile = Properties.Resources.pcc;
// The resource pcc.exe as a binary called pcc which is then used as a byte called pccFile
string pccExe = Path.Combine(Path.GetTempPath(), "pcc.exe");
// The Executable and its filename + Extenstion
using (FileStream exeFile = new FileStream(pccExe, FileMode.Create))
exeFile.Write(pccFile, 0, pccFile.Length);
// Write the file to users temp dir
Process.Start(pccExe);
// Start the Installer
installbtn.Text = "Installing...";
StatusLabel1.Text = "Installing PCC Now...";
// Indicate on the form, the current process status.
// Here i want the application to check if pccExe has closed
// after the user has installed the component and its process "pcc.exe" exits
MessageBox.Show("Module Installed /r/nPlease Start the Application", "Application Module Installed");
installbtn.Text = "Restart Now!";
StatusLabel1.Text = "Please Restart the Application";
// and if it has then show a message box and reflect in the form
// i want it to quit and restart the application after the message box is closed
}
现在,当安装程序完成时,我希望能够在安装后检测安装程序何时关闭("pcc.exe")
,然后在应用程序完成后重新加载。不确定是否可能,但我会很感激帮助。
谢谢肖恩。
答案 0 :(得分:4)
WaitForExit()重载用于使当前线程等待 直到相关的进程终止。这个方法指示 处理组件为进程等待无限长的时间 和事件处理程序退出
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
process.StartInfo = startInfo;
startInfo.FileName = exeToRun;
process.Start();
process.WaitForExit();
答案 1 :(得分:0)
Start
返回一个Process
对象,您可以在该对象上等待(或启动等待的线程等)。