forked from abinchy/sysproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (50 loc) · 1.77 KB
/
Program.cs
File metadata and controls
52 lines (50 loc) · 1.77 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using trayproxy.Util;
using trayproxy.View;
namespace trayproxy
{
internal static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
if (!Runtime.IsWinVistaOrHigher())
{
MsgBox.Error("Unsupported operating system,use Windows 7 at least");
return;
}
if (!Runtime.GetVersionFromRegistry())
{
if (DialogResult.OK == MsgBox.ErrorRes("Unsupported .NET Framework,require 4.8 version"))
{
Process.Start("https://dotnet.microsoft.com/download/dotnet-framework");
}
return;
}
//Check running trayproxy
using (Mutex mutex = new Mutex(false, "Global\\trayproxy" + Application.StartupPath.GetHashCode()))
{
//SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
if (!mutex.WaitOne(0, false))
{
Process[] oldProcesses = Process.GetProcessesByName("trayproxy");
if (oldProcesses.Length > 0)
{
MsgBox.Show(I18N.GetString("Find trayproxy icon in your notify tray,which is usually on bottom right corner"));
return;
}
}
FileHelper.AppPath = Application.StartupPath;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TrayMenuView());
}
}
}
}