Пример #1
0
        // set ie proxy to all connections
        public static void SetSystemProxy(SystemProxyOption option, string proxyServer, string pacUrl)
        {
            string[] allConnections = null;


            var ret = RemoteAccessService.GetAllConns(ref allConnections);

            if (ret == 2)
            {
                throw new Exception("Cannot get all connections");
            }
            else if (ret == 1)
            {
                // no entries, only set LAN
                SetSystemProxy(option, proxyServer, pacUrl, null);
            }
            else if (ret == 0)
            {
                SetSystemProxy(option, proxyServer, pacUrl, null);
                foreach (string connName in allConnections)
                {
                    //Console.WriteLine($"Connection name: {connName}");
                    SetSystemProxy(option, proxyServer, pacUrl, connName);
                }
            }
        }
Пример #2
0
        // connName = null for LAN
        public static void SetSystemProxy(SystemProxyOption option, string proxyServer, string pacUrl, string connName)
        {
            switch (option)
            {
            case SystemProxyOption.Proxy_None:
                SetSystemProxy(false, false, null, null, connName);
                break;

            case SystemProxyOption.Proxy_Direct:
                SetSystemProxy(true, true, proxyServer, null, connName);
                break;

            case SystemProxyOption.Proxy_PAC:
                SetSystemProxy(true, false, null, pacUrl, connName);
                break;

            default:
                break;
            }
        }