winfrom程序只启动一个exe进程

   private static void KillProcess()
        {
            Process process1 = Process.GetCurrentProcess();
            //获得当前计算机系统内某个进程并关闭:
            System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcessesByName(process1.ProcessName);
            foreach (System.Diagnostics.Process p in process)
            {
                if (p.Id != process1.Id)
                {
                    p.Kill();
                }
            }
        }

  

 

posted @ 2022-08-30 10:15  fulllove  阅读(57)  评论(0)    收藏  举报