c#读取进程列表判断程序是否已经启动(转)
方法一: using System.Diagnostics; Process[] vProcesses = Process.GetProcesses(); foreach (Process vProcess in vProcesses) if (vProcess.ProcessName.Equals( "iexplore ", StringComparison.OrdinalIgnoreCase)) { MessageBox.Show( "IE已经打开 "); break; } 方法二: using System.Diagnostics; Process[] app = Process.GetProcessesByName("AMS"); if (app.Length > 0) { MessageBox.Show("请关闭已经启动的程序后再进行尝试"); return; } else { System.Diagnostics.Process.Start("AMS.exe"); } 杀死进程:查找到对应的进程后就可以调用系统命令杀死指定名称的进程 Process[] p = Process.GetProcessesByName("AMS"); foreach (Process ps in p) { ps.Kill(); }