1. 程式人生 > >通過註冊表修改IE瀏覽器內核版本

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

on() gis exec try exceptio 整理 feature setvalue rem

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瀏覽器內核版本