首页 > 代码库 > C#Winform程序防多开限制

C#Winform程序防多开限制

 

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

 

System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName(Application.CompanyName);
if (processes.Length > 1)
{
MessageBox.Show("应用程序已经在运行中!");
Thread.Sleep(1000);
System.Environment.Exit(1);
}
else
{
Application.Run(new Form1());
}

 

C#Winform程序防多开限制