using System.Diagnostics; Process[] myprocess = Process.GetProcesses();//获取进程 foreach (Process pro in myprocess) { if (pro.MainWindowTitle.Length > 0) { pro.MainWindowTitle);//进程主窗口标题作为项添加 pro.ProcessName;//保存进程名 } } Process[] myProcesses = Process.GetProcessesByName(""); foreach (Process myProcess in myProcesses) { if (myProcess.Responding) myProcess.CloseMainWindow();//关闭进程 else myProcess.Kill();//关闭进程 }
时间: 2024-10-21 05:05:01