This commit is contained in:
2dust 2021-05-15 11:53:39 +08:00
parent 7513ff860b
commit a70b5eeef5
3 changed files with 26 additions and 7 deletions

View file

@ -33,7 +33,7 @@ namespace v2rayN.Forms
Application.ApplicationExit += (sender, args) => Application.ApplicationExit += (sender, args) =>
{ {
MyAppExit(); MyAppExit(false);
}; };
} }
@ -88,8 +88,10 @@ namespace v2rayN.Forms
case CloseReason.ApplicationExitCall: case CloseReason.ApplicationExitCall:
case CloseReason.FormOwnerClosing: case CloseReason.FormOwnerClosing:
case CloseReason.TaskManagerClosing: case CloseReason.TaskManagerClosing:
MyAppExit(false);
break;
case CloseReason.WindowsShutDown: case CloseReason.WindowsShutDown:
MyAppExit(); MyAppExit(true);
break; break;
} }
} }
@ -105,14 +107,21 @@ namespace v2rayN.Forms
//} //}
} }
private void MyAppExit() private void MyAppExit(bool blWindowsShutDown)
{ {
try try
{ {
v2rayHandler.V2rayStop(); v2rayHandler.V2rayStop();
//HttpProxyHandle.CloseHttpAgent(config); //HttpProxyHandle.CloseHttpAgent(config);
if (blWindowsShutDown)
{
HttpProxyHandle.ResetIEProxy4WindowsShutDown();
}
else
{
HttpProxyHandle.UpdateSysProxy(config, true); HttpProxyHandle.UpdateSysProxy(config, true);
}
ConfigHandler.SaveConfig(ref config); ConfigHandler.SaveConfig(ref config);
statistics?.SaveToFile(); statistics?.SaveToFile();

View file

@ -170,8 +170,6 @@ namespace v2rayN.HttpProxyHandler
} }
else if (type == ESysProxyType.ForcedClear) else if (type == ESysProxyType.ForcedClear)
{ {
//TODO To be verified
Utils.RegWriteValue(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 0);
SysProxyHandle.ResetIEProxy(); SysProxyHandle.ResetIEProxy();
} }
else if (type == ESysProxyType.Unchanged) else if (type == ESysProxyType.Unchanged)
@ -184,5 +182,17 @@ namespace v2rayN.HttpProxyHandler
} }
return true; return true;
} }
public static void ResetIEProxy4WindowsShutDown()
{
try
{
//TODO To be verified
Utils.RegWriteValue(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable", 0);
}
catch
{
}
}
} }
} }

View file

@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”: // 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")] //[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("4.16")] [assembly: AssemblyFileVersion("4.17")]