X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=KancolleSniffer%2FSystemProxy.cs;h=d49bfa1be6b0e6357140992b1878287686a4db37;hb=d31202c62b3f33b4432d253b816728ee83f8041b;hp=d8cd87b102362273c0c2449528bebdc4e448569e;hpb=2bc6c8271bf8e9dc0e5276c1f8ddd8c7235e3948;p=kancollesniffer%2FKancolleSniffer.git diff --git a/KancolleSniffer/SystemProxy.cs b/KancolleSniffer/SystemProxy.cs index d8cd87b..d49bfa1 100644 --- a/KancolleSniffer/SystemProxy.cs +++ b/KancolleSniffer/SystemProxy.cs @@ -22,7 +22,7 @@ namespace KancolleSniffer public class SystemProxy { private InternetPerConnOptionList _orgList; - private string _currentUrl; + private Uri _initialUri; private void SaveSettings() { @@ -54,7 +54,8 @@ namespace KancolleSniffer SaveSettings(); var flagValue = new InternetPerConnOptionValue {dwValue = (int)PerConnFlags.PROXY_TYPE_AUTO_PROXY_URL}; var urlValue = new InternetPerConnOptionValue {pszValue = Marshal.StringToHGlobalAuto(url)}; - _currentUrl = url; + if (_initialUri == null) + Uri.TryCreate(url, UriKind.Absolute, out _initialUri); var opts = new[] { new InternetPerConnOption {dwOption = PerConnOption.INTERNET_PER_CONN_FLAGS, Value = flagValue}, @@ -85,8 +86,8 @@ namespace KancolleSniffer var size = Marshal.SizeOf(typeof(InternetPerConnOption)); var urlOpt = (InternetPerConnOption) Marshal.PtrToStructure((IntPtr)((long)_orgList.pOptions + size), typeof(InternetPerConnOption)); - var orgUrl = Marshal.PtrToStringUni(urlOpt.Value.pszValue); - if (orgUrl == _currentUrl) // The restoration was sikipped or failed at last time. + Uri.TryCreate(Marshal.PtrToStringUni(urlOpt.Value.pszValue) ?? "", UriKind.Absolute, out var orgUri); + if (orgUri?.Authority == _initialUri?.Authority) // The restoration was sikipped or failed at last time. { // Unselect the Use automatic configration script check box. var flagsOpt =