Example #1
0
        /// <summary>
        /// WinHTTPでIEプロキシ設定を取得。
        /// </summary>
        /// <returns></returns>
        private static WinHttpCurrentUserIEProxyConfig WinHttpGetIEProxyConfigForCurrentUser()
        {
            //ここだけWinINetではない……
            var ieProxyConfig = new WinHttpCurrentUserIEProxyConfig();

            NativeMethods.WinHttpGetIEProxyConfigForCurrentUser(ref ieProxyConfig);
            return(ieProxyConfig);
        }
Example #2
0
        private void GetSystemProxy()
        {
            var proxyConfig = new WinHttpCurrentUserIEProxyConfig();

            Win32Utils.WinHttpGetIEProxyConfigForCurrentUser(ref proxyConfig);
            if (string.IsNullOrEmpty(proxyConfig.Proxy))
            {
                GlobalData.VM_MA.ProxySystem = string.Empty;
            }
            else
            {
                if (!proxyConfig.Proxy.Contains("="))
                {
                    GlobalData.VM_MA.ProxySystem = proxyConfig.Proxy;
                }
                else
                {
                    var settings = proxyConfig.Proxy.Split(';');
                    foreach (var setting in settings)
                    {
                        var groups = GlobalRegex.ProxyPattern.Match(setting).Groups;
                        if (groups.Count < 1)
                        {
                            continue;
                        }
                        switch (groups["scheme"].Value)
                        {
                        case "http":
                            if (ushort.TryParse(groups["port"].Value, out var httpPort))
                            {
                                GlobalData.VM_MA.ProxySystem = $"{groups["host"].Value}:{httpPort}";
                            }
                            return;

                        default:
                            break;
                        }
                    }
                    GlobalData.VM_MA.ProxySystem = string.Empty;
                }
            }
        }
Example #3
0
 internal static extern bool WinHttpGetIEProxyConfigForCurrentUser(ref WinHttpCurrentUserIEProxyConfig pProxyConfig);