方法一:
Process[] processes = rocess.GetProcessesByName("ConDemo"); if (processes.Length > 1) { MessageBox.Show("应用程序已经在运行","提示"); }
方法二:
private Mutex mutex; this.mutex = new Mutex(true, name, out flag);//name传入的是进程名称 if (!flag) { MsgBox.ShowMessage("已经启动了一个程序!"); Process.GetCurrentProcess().Kill(); return; }