C#杀死Word,Excel等进程

 

private void KillProcess(string processName)

{

System.Diagnostics.Process myproc= new System.Diagnostics.Process();

//得到所有打开的进程

    try{

    foreach (Process thisproc in Process.GetProcessesByName(processName)) {

       if(!thisproc.CloseMainWindow()){

	thisproc.Kill();

	}

        }

      }

    catch(Exception Exc)

    {

        msg.Text+= "杀死" + processName + "失败!";

    }

}

 

 转载自:http://www.wpf8.net/news/CSharp/201306/367.html

你可能感兴趣的:(Excel)