static class Program
{
static Mutex mutex;
[STAThread]
static void Main()
{
#region Make Sure Only One Application is Running
bool newApp = false;
try
{
Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().ProcessName);
mutex = new System.Threading.Mutex(false, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out newApp);
if (newApp == false)
{
MessageBox.Show("应用程序已经存在,请勿重复打开!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Environment.Exit(0);
}
}
catch
{
MessageBox.Show("应用程序已经存在,请勿重复打开!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Environment.Exit(0);
}
#endregion
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
}