查看 IE 版本 和 Enable IE Security configuration and compatibility

/// <summary>
        /// SetIECompatibilityView
        /// </summary>
        public static void SetIECompatibilityView()
        {
            try
            {
                RegistryKey key = Registry.CurrentUser;
                RegistryKey software = key.OpenSubKey(@"Software\Microsoft\Internet Explorer\BrowserEmulation", true);

                if (IsgetKeys(software, "AllSitesCompatibilityMode"))
                {
                    software.SetValue("AllSitesCompatibilityMode", "1", RegistryValueKind.DWord);
                }
                else
                {
                    software.CreateSubKey("AllSitesCompatibilityMode");
                    software.SetValue("AllSitesCompatibilityMode", "1", RegistryValueKind.DWord);
                }
                if (IsgetKeys(software, "MSCompatibilityMode"))
                {
                    software.SetValue("MSCompatibilityMode", "1", RegistryValueKind.DWord);
                }
                else
                {
                    software.CreateSubKey("MSCompatibilityMode");
                    software.SetValue("MSCompatibilityMode", "1", RegistryValueKind.DWord);
                }
                if (IsgetKeys(software, "UnattendLoaded"))
                {
                    software.SetValue("UnattendLoaded", "1", RegistryValueKind.DWord);
                }
                else
                {
                    software.CreateSubKey("UnattendLoaded");
                    software.SetValue("UnattendLoaded", "1", RegistryValueKind.DWord);
                }
                if (IsgetKeys(software, "IntranetCompatibilityMode"))
                {
                    software.SetValue("IntranetCompatibilityMode", "1", RegistryValueKind.DWord);
                }
                else
                {
                    software.CreateSubKey("IntranetCompatibilityMode");
                    software.SetValue("IntranetCompatibilityMode", "1", RegistryValueKind.DWord);
                }
                software.Close();
            }
            catch { }


        }
/// <summary>
        /// ConfigureIEfirstLaunch
        /// </summary>
        public static void ConfigureIEfirstLaunch()
        {
            RegistryKey key = Registry.CurrentUser;
            RegistryKey software = key.OpenSubKey(@"Software\Microsoft\Internet Explorer", true);
            software = software.CreateSubKey("PhishingFilter");
            RegistryKey keyLocal = Registry.LocalMachine;
            RegistryKey softwareLocal = keyLocal.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer", true);
            softwareLocal = softwareLocal.CreateSubKey("PhishingFilter");
            string keystring = "";
            if (getIEversion() == "8")
            {
                keystring = "EnabledV8";
            }
            if (getIEversion() == "9")
            {
                keystring = "EnabledV9";
            }
            if (IsgetKeys(softwareLocal, keystring))
            {
                softwareLocal.SetValue(keystring, "1", RegistryValueKind.DWord);
            }
            else
            {
                softwareLocal.CreateSubKey(keystring);
                softwareLocal.SetValue(keystring, "1", RegistryValueKind.DWord);
            }
            if (IsgetKeys(software, keystring))
            {
                software.SetValue(keystring, "1", RegistryValueKind.DWord);
            }
            else
            {
                software.CreateSubKey(keystring);
                software.SetValue(keystring, "1", RegistryValueKind.DWord);
            }
        }
 public static bool IsgetKeys(RegistryKey software, string name)
        {
            string[] subkeyNames = software.GetValueNames();
            bool isExists = false;
            foreach (string keys in subkeyNames)
            {
                if (keys.Equals(name))
                {
                    isExists = true;
                    break;
                }
                else
                {
                    isExists = false;
                }
            }
            return isExists;

        }
        public static string getIEversion()
        {
            string IEVersion = "";
            RegistryKey key = Registry.LocalMachine;
            RegistryKey software = key.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer", true);
            IEVersion = software.GetValue("Version").ToString().Substring(0, 1);
            return IEVersion;
        }

 

 

 

转载于:https://www.cnblogs.com/VDTy/archive/2013/01/16/2862966.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值