通过修改注册表的值,来指定winform程序打开的webBrowser的IE版本
1>方法一,通过程序修改注册表的值
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/// <summary>
/// 定义IE版本的枚举
/// </summary>
private enum IeVersion
{
强制ie10,
标准ie10,
强制ie9,
标准ie9,
强制ie8,
标准ie8,
标准ie7
}
/// <summary>
/// 设置WebBrowser的默认版本
/// </summary>
/// <param name="ver">IE版本</param>
private void SetIE( IeVersion ver)
{
string productName = AppDomain.CurrentDomain.SetupInformation.ApplicationName;
object version;
switch (ver)
{
case IeVersion.标准ie7:
version = 0x1B58;
break ;
case IeVersion.标准ie8:
version = 0x1F40;
break ;
case IeVersion.强制ie8:
version = 0x22B8;
break ;
case IeVersion.标准ie9:
version = 0x2328;
break ;
case IeVersion.强制ie9:
version = 0x270F;
break ;
case IeVersion.标准ie10:
version = 0x02710;
break ;
case IeVersion.强制ie10:
version = 0x2711;
break ;
default :
version = 0x1F40;
break ;
}
RegistryKey key = Registry.CurrentUser;
RegistryKey software =
key.CreateSubKey(
@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\" + productName);
if (software != null )
{
software.Close();
software.Dispose();
}
RegistryKey wwui =
key.OpenSubKey(
@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" , true );
if (wwui != null ) wwui.SetValue(productName, version, RegistryValueKind.DWord);
}
|
参考:https://www.cnblogs.com/codeyou/p/4943017.html
2>方法二:手动修改注册表的值
假设winform程序的名称是TestWebBrowser.exe。
1、在开始菜单内输入“regedit.exe”,进入注册表编辑器
2、找到注册表项:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
3、在右侧空白区域内单击鼠标右键,点击【新建】→【DWORD(32-位)值】
4、新建的项取名为TestWebBrowser.exe,编辑值时,选择基数“十进制”,填写数值数据,这里填写8888
5、这个时候再进入Debug目录下生成好的TestWebBrowser,可以看到登录的内核版本变成IE8了!
参考:https://blog.csdn.net/herogui/article/details/51982474
|
请发表评论