2022-02-07
Process process = System.Diagnostics.Process.GetProcesses();
一个类:
using System.Diagnostics; using System; using System.Collections; using System.Collections.Generic; namespace core_admin.utils{ public class ProcessFinder{ Process[] processes = System.Diagnostics.Process.GetProcesses(); List<string> ret = new List<string>(); for(int i=0;i<processes.Length;i++){ Process item = processes[i]; ret.Add(item.ProcessName); } return ret; } public static string isProcessRunning(string processName){ List<string> processes = getRunningProcesses(); foreach(string a_process in processes){ if(System.IO.Path.GetFileNameWithoutExtension(a_process.ToLower()) ==System.IO.Path.GetFileNameWithoutExtension(processName.ToLower())){ return a_process; } } return ""; } } } |