通過注冊表修改IE瀏覽器內核版本


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日


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM