static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mainForm = new Main(); bool ExisFlag = false; System.Diagnostics.Process currentProccess = System.Diagnostics.Process.GetCurrentProcess(); System.Diagnostics.Process[] currentProccessArray = System.Diagnostics.Process.GetProcesses(); foreach (System.Diagnostics.Process p in currentProccessArray) { if (p.ProcessName == currentProccess.ProcessName && p.Id != currentProccess.Id) { ExisFlag = true; break; } } if (ExisFlag) { MessageBox.Show("仓储调度监控系统!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { Application.Run(mainForm); } }
static void Main() { using (var game = new Main()) game.Run(); }