首页 > 其他 > 详细

通过注册表修改IE浏览器内核版本

时间:2017-11-30 17:02:24      阅读:585      评论:0      收藏:0      [点我收藏+]

static public void SetIERegistry()
{
  try
  {
   //获取系统IE版本号
   string strIEVersion = SysIeVersion();
   if (string.IsNullOrEmpty(strIEVersion) || strIEVersion.Split(‘.‘).Length < 1)
   return;

   //注册表版本号
   int strValue = int.Parse(strIEVersion.Split(‘.‘).GetValue(0).ToString()) * 1000;

   //不一样 修改注册表
   RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);//打开注册表子项
   if (key == null)
   key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION");

   string strAppName = Path.GetFileName(Application.ExecutablePath);

   if (key.GetValue(strAppName) == null || key.GetValue(strAppName).ToString() != strValue.ToString())
   {
      key.SetValue(strAppName, strValue, RegistryValueKind.DWord);
   }
   key.Close();
 }
 catch (Exception ex)
 {
   Console.WriteLine(ex.Message);
 }
}

//获取系统IE版本号
static public string SysIeVersion()
{
  RegistryKey versionKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Internet Explorer");
  try
  {
    return versionKey.GetValue("Version").ToString();
  }
  finally
  {
    versionKey.Close();
  }
}

 

 

----------------------------------------------------------------------------
创建于2017年6月29日

整理于2017年11月30日

通过注册表修改IE浏览器内核版本

原文:http://www.cnblogs.com/kanjinxiang/p/7929560.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!