-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
36 lines (34 loc) · 1.12 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Threading;
using System.Windows.Forms;
namespace _2x
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
bool createdNew;
// 创建一个唯一的 Mutex 名称来确保应用程序只运行一个实例
using (Mutex mutex = new Mutex(true, "ProxySwitcherMutex", out createdNew))
{
if (createdNew)
{
// 如果是新创建的实例,启动应用程序
Application.Run(new Form1());
}
else
{
// 如果实例已经存在,则显示一个消息框并退出程序
MessageBox.Show("应用程序已经在运行中。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
}