|
|
|
@ -1,18 +1,13 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Threading; |
|
|
|
|
using System.Windows.Forms; |
|
|
|
|
using v2rayN.Forms; |
|
|
|
|
using v2rayN.Properties; |
|
|
|
|
using v2rayN.Tool; |
|
|
|
|
|
|
|
|
|
namespace v2rayN |
|
|
|
|
{ |
|
|
|
|
static class Program |
|
|
|
|
{ |
|
|
|
|
[System.Runtime.InteropServices.DllImport("user32.dll")] |
|
|
|
|
private static extern bool SetProcessDPIAware(); |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 应用程序的主入口点。 |
|
|
|
|
/// </summary> |
|
|
|
@ -21,7 +16,7 @@ namespace v2rayN
|
|
|
|
|
{ |
|
|
|
|
if (Environment.OSVersion.Version.Major >= 6) |
|
|
|
|
{ |
|
|
|
|
SetProcessDPIAware(); |
|
|
|
|
Utils.SetProcessDPIAware(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); |
|
|
|
@ -47,6 +42,22 @@ namespace v2rayN
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
//read handle from reg and show the window |
|
|
|
|
long.TryParse(Utils.RegReadValue(Global.MyRegPath, Utils.WindowHwndKey, ""), out long llong); |
|
|
|
|
if (llong > 0) |
|
|
|
|
{ |
|
|
|
|
var hwnd = (IntPtr)llong; |
|
|
|
|
if (Utils.IsWindow(hwnd)) |
|
|
|
|
{ |
|
|
|
|
Utils.ShowWindow(hwnd, 4); |
|
|
|
|
Utils.SwitchToThisWindow(hwnd, true); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch { } |
|
|
|
|
UI.ShowWarning($"v2rayN is already running(v2rayN已经运行)"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|