winform webbrowser如何強制使用ie11內核?


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.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM