webkit.net ,cefsharp,openwebkit.net等这些基于谷歌或者基于firfox内核的浏览器有个共同点,就是必须指定winform为x86的才能使用,
而且使用过程中也是各种坑需要去填。
webbrowser不好的地方是默认使用ie5内核来加载网页,不得不吐槽下微软真是奇葩,ie已经退出了历史舞台,但是winform里面的webbrowser控件使用的还是ie内核,
项目有个需求是,winform程序,必须是x64的,x86经常内存溢出,于是,那些基于谷歌内核的都被pass掉了。
winform里面嵌套的网站之前都是基于谷歌内核来开发的,在ie11里面虽然还有一些小瑕疵,但是毕竟可以使用,
于是考虑如何让winform x64调用IE11的内核。
代码如下:
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
if (key != null)
{
key.SetValue("XXX.exe", 11001, RegistryValueKind.DWord);
key.SetValue("XXX.vshost.exe", 11001, RegistryValueKind.DWord);//调试运行需要加上,否则不起作用
}
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
if (key != null)
{
key.SetValue("XXX.exe", 11001, RegistryValueKind.DWord);
key.SetValue("XXX.vshost.exe", 11001, RegistryValueKind.DWord);//调试运行需要加上,否则不起作用
}
IE各版本的值如下:
- 11001 (0x2EDF) Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive
- 11000 (0x2AF8) :Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode
- 10000 (0x2710) :Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
- 10001 (0x2AF7) :Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
- 9999 (0x270F) :Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
- 9000 (0x2328) :Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
- 8888 (0x22B8) :Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
- 8000 (0x1F40) :Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
- 7000 (0x1B58) :Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.