1 // Copyright (C) 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
16 using System.Runtime.InteropServices;
\r
17 using Microsoft.Win32;
\r
19 // ReSharper disable InconsistentNaming
\r
21 namespace KancolleSniffer
\r
23 public static class SystemProxy
\r
25 private const string _regPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
\r
26 private const string _regName = "AutoConfigURL";
\r
28 public static string AutoConfigUrl
\r
32 using (var regkey = Registry.CurrentUser.OpenSubKey(_regPath))
\r
36 return regkey.GetValue(_regName) as string ?? "";
\r
41 using (var regkey = Registry.CurrentUser.OpenSubKey(_regPath, true))
\r
47 regkey.DeleteValue(_regName, false);
\r
51 regkey.SetValue(_regName, value);
\r
59 /// PACファイルでDIRECTを指定すると、すべてのサイトがローカルイントラネットになり、
\r
60 /// IEが互換表示になるなどの不具合があるので、イントラネットにならないようにする
\r
62 public static void AdjustLocalIntranetZoneFlags()
\r
64 var zones = Registry.CurrentUser.OpenSubKey(_regPath + @"\Zones\1", true);
\r
67 if (!(zones.GetValue("Flags") is int flags))
\r
69 zones.SetValue("Flags", flags & (-1 ^ 0x108));
\r
72 public static void Refresh()
\r
74 InternetSetOption(IntPtr.Zero, InternetOption.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
\r
75 InternetSetOption(IntPtr.Zero, InternetOption.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
\r
78 [DllImport("WinInet.dll", SetLastError = true, CharSet = CharSet.Auto)]
\r
79 private static extern bool InternetSetOption(IntPtr hInternet, InternetOption dwOption,
\r
80 IntPtr lpBuffer, int dwBufferLength);
\r
82 private enum InternetOption : uint
\r
84 INTERNET_OPTION_REFRESH = 37,
\r
85 INTERNET_OPTION_SETTINGS_CHANGED = 39
\r