您的位置:首页 > 编程语言 > C#

c# 关闭进程

2009-04-16 08:18 176 查看
//关闭进程
public void KillProcess(string processName)
{
System.Diagnostics.Process myproc = new System.Diagnostics.Process();
//得到所有打开的进程
try
{
foreach (Process thisproc in Process.GetProcessesByName(processName))
{
if (!thisproc.CloseMainWindow())
{
if (thisproc != null)
thisproc.Kill();
}
}
}
catch (Exception Exc)
{
throw Exc;
// msg.Text+= "杀死" + processName + "失败!";
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: