日期:2014-05-18 浏览次数:20812 次
foreach (Process p in Process.GetProcesses()) { // 查找 p.ProcessName ,做你自己的事情,打开和关闭,看帮助 }
------解决方案--------------------
/// <summary>
/// 关闭需要更新软件的进程
/// </summary>
/// <param name="strProcessesByName">进程名称</param>
public void KillProcess(string strProcessesByName)
{
foreach (Process p in System.Diagnostics.Process.GetProcessesByName(strProcessesByName))
{
try
{
p.Kill();
p.WaitForExit(); // possibly with a timeout
}
catch (Win32Exception winException)
{
// process was terminating or can't be terminated - deal with it
}
catch (InvalidOperationException invalidException)
{
// process has already exited - might be able to let this one go
}
}
}
------解决方案--------------------
foreach (Process p in Process.GetProcesses())
{
// 查找 p.ProcessName ,做你自己的事情,打开和关闭,看帮助
}
------解决方案--------------------
同意的+1
------解决方案--------------------
打开进程:Thread th = new Thread(new ThreadStart(GetCurrentReport)); th.Start();
GetCurrentReport 他是你要执行进程的那个方法。
Process.GetCurrentProcess().Kill(); 是杀掉进程,你可以在当窗体关闭时的事件中执行此段代码,也就是当关闭窗体时进程也关掉