private static System.Threading.Mutex mutex;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
bool runNew;
mutex = new System.Threading.Mutex(true, "myproject", out runNew);
if (runNew)
{
mutex.ReleaseMutex();
// Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show("程序已经在运行。");
}
}
时间: 2024-09-25 19:10:39