Skip to content

Commit

Permalink
Fix Proxy setting not effect immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
zjyl1994 committed Mar 12, 2018
1 parent c8aead8 commit 915e762
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 7 deletions.
17 changes: 11 additions & 6 deletions V2Switcher/ProxyManager.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace V2Switcher
{
class ProxyManager
{
// 刷新代理设置
[DllImport("wininet.dll")]
public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
public const int INTERNET_OPTION_SETTINGS_CHANGED = 39;
public const int INTERNET_OPTION_REFRESH = 37;
bool settingsReturn, refreshReturn;

private static ProxyManager uniqueInstance; // 单例句柄

private Config current; // 当前配置
Expand Down Expand Up @@ -72,6 +74,9 @@ public bool Enable {
internetSetting.SetValue("ProxyEnable", 0, RegistryValueKind.DWord);
}
internetSetting.Close();
// 刷新代理设置
settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
refreshReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion V2Switcher/V2Switcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\..\v2ray\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions V2Switcher/obj/Debug/V2Switcher.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ D:\workspace\V2Switcher\V2Switcher\obj\Debug\V2Switcher.exe
D:\workspace\V2Switcher\V2Switcher\obj\Debug\V2Switcher.pdb
D:\workspace\V2Switcher\V2Switcher\obj\Debug\V2Switcher.Properties.Resource.resources
D:\workspace\V2Switcher\V2Switcher\bin\Debug\Newtonsoft.Json.dll
D:\needtotest\V2Switcher\V2Switcher\bin\Debug\V2Switcher.exe.config
D:\needtotest\V2Switcher\V2Switcher\obj\Debug\V2Switcher.exe
D:\needtotest\V2Switcher\V2Switcher\obj\Debug\V2Switcher.pdb
D:\needtotest\V2Switcher\V2Switcher\obj\Debug\V2Switcher.csprojResolveAssemblyReference.cache
D:\needtotest\V2Switcher\V2Switcher\obj\Debug\V2Switcher.Properties.Resource.resources
D:\needtotest\V2Switcher\V2Switcher\obj\Debug\V2Switcher.csproj.GenerateResource.Cache
D:\needtotest\V2Switcher\V2Switcher\bin\Debug\V2Switcher.exe
D:\needtotest\V2Switcher\V2Switcher\bin\Debug\V2Switcher.pdb
D:\needtotest\V2Switcher\V2Switcher\bin\Debug\Newtonsoft.Json.dll
Binary file modified V2Switcher/obj/Debug/V2Switcher.csproj.GenerateResource.Cache
Binary file not shown.
Binary file not shown.
Binary file modified V2Switcher/obj/Debug/V2Switcher.exe
Binary file not shown.
Binary file modified V2Switcher/obj/Debug/V2Switcher.pdb
Binary file not shown.
Binary file not shown.

0 comments on commit 915e762

Please sign in to comment.