コード例 #1
0
ファイル: WinInetInterop.cs プロジェクト: qunqiang/IEProxy
        private static bool CheckProxyFlag(PerConnectionFlags proxyFlagToCheck)
        {
            InternetPerConnectionOption returnOption = GetInternetConnectionOption(PerConnectionOption.INTERNET_PER_CONNECTION_FLAGS);

            // Since this returns an int that contains the value of many flags
            // we need to AND the value against what we're looking for and
            // then compare it against our value if it returns true it was set.
            int andValue = returnOption.value.valueInt & (int)proxyFlagToCheck;

            return(andValue == (int)proxyFlagToCheck);
        }
コード例 #2
0
ファイル: WinInetInterop.cs プロジェクト: qunqiang/IEProxy
        private static bool SwitchInternetProxy(PerConnectionFlags proxyFlagToSet, bool enableProxy)
        {
            InternetPerConnectionOption currentOption = GetInternetConnectionOption(PerConnectionOption.INTERNET_PER_CONNECTION_FLAGS);

            if (enableProxy)
            {
                //To add this setting do a bitwise OR against the current value
                //(compare the value bit by bit if either of the values has that bit set leave it set)
                //this will essentially turn on this portion of the proxy flag.
                currentOption.value.valueInt |= (int)proxyFlagToSet;
            }
            else
            {
                //To remove this setting do a bitwise XOR against the current value
                //(compare the value bit by bit if one and only one of the two has that bit set leave it set)
                //this will essentially turn off this portion of the proxy flags.
                currentOption.value.valueInt ^= (int)proxyFlagToSet;
            }

            InternetPerConnectionOption[] options = new InternetPerConnectionOption[1];
            options[0] = currentOption;
            return(CallInternetSetOption(options));
        }
コード例 #3
0
ファイル: WinInetInterop.cs プロジェクト: coolshou/IEProxy
        private static bool SwitchInternetProxy(PerConnectionFlags proxyFlagToSet, bool enableProxy)
        {
            InternetPerConnectionOption currentOption = GetInternetConnectionOption(PerConnectionOption.INTERNET_PER_CONNECTION_FLAGS);

            if (enableProxy)
            {
                //To add this setting do a bitwise OR against the current value
                //(compare the value bit by bit if either of the values has that bit set leave it set)
                //this will essentially turn on this portion of the proxy flag.
                currentOption.value.valueInt |= (int)proxyFlagToSet;
            }
            else
            {
                //To remove this setting do a bitwise XOR against the current value
                //(compare the value bit by bit if one and only one of the two has that bit set leave it set)
                //this will essentially turn off this portion of the proxy flags.
                currentOption.value.valueInt ^= (int)proxyFlagToSet;
            }

            InternetPerConnectionOption[] options = new InternetPerConnectionOption[1];
            options[0] = currentOption;
            return CallInternetSetOption(options);
        }
コード例 #4
0
ファイル: WinInetInterop.cs プロジェクト: coolshou/IEProxy
        private static bool CheckProxyFlag(PerConnectionFlags proxyFlagToCheck)
        {
            InternetPerConnectionOption returnOption = GetInternetConnectionOption(PerConnectionOption.INTERNET_PER_CONNECTION_FLAGS);

            // Since this returns an int that contains the value of many flags
            // we need to AND the value against what we're looking for and
            // then compare it against our value if it returns true it was set.
            int andValue = returnOption.value.valueInt & (int)proxyFlagToCheck;
            return (andValue == (int)proxyFlagToCheck);
        }