(轉)C#修改WebBrowser核心版本
最近在寫一個專案,用HTML寫介面,所以需要用JS和視窗程式進行互動.
但是預設的IE核心實在太渣了,得知能夠修改登錄檔來更改預設核心版本,但是寫程式碼的時候卻怎麼都不行.
去谷歌了一下果斷找到了一個有效的程式碼,檢查對比了下是登錄檔弄錯了..
貼上正確的程式碼,作為記錄
public void setIEcomp()
{
String appname = Process.GetCurrentProcess().ProcessName + ".exe";
RegistryKey RK8 = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree);
int value9 = 9999;
int value8 = 8888;
Version ver = WebBrowser.Version;
int value = value9;
try
{
string[] parts = ver.ToString().Split('.');
int vn = 0;
int.TryParse(parts[0], out vn);
if (vn != 0)
{
if (vn == 9)
value = value9;
else
value = value8;
}
}
catch
{
value = value9;
}
//Setting the key in LocalMachine
if (RK8 != null)
{
try
{
RK8.SetValue(appname, value, RegistryValueKind.DWord);
RK8.Close();
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
}
轉:https://blog.csdn.net/a323226341/article/details/52620554