日期:2014-05-18 浏览次数:20870 次
bool flag = false; Process current = Process.GetCurrentProcess(); System.Threading.Mutex mutex = new System.Threading.Mutex(true, current.ProcessName, out flag); if (flag) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } catch { Application.Exit(); } } else { Application.Exit(); return; }
static System.Threading.Mutex mutex; //<-- void static Main() { bool flag = false; Process current = Process.GetCurrentProcess(); mutex = new System.Threading.Mutex(true, current.ProcessName, out flag); //<--- if (flag) ...