最近在写一个项目,用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