using DevicesService.Commen; using DevicesService.Common; using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; namespace DevicesService { internal class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main(string[] args) { // 更改为你想检查的进程名称 new COMUtils(); while (true) { Task.Delay(2000).Wait(); } } static bool IsProgramRunning(string programName) { Process[] processes = Process.GetProcesses(); foreach (Process process in processes) { if (process.ProcessName.Equals(programName)) { return true; } } return false; } } }