Delphi 强制让TWebBrowser以ie11访问网站

最近想把一个网站放在exe中访问,这个网站只在ie11下才能正常运行,比较奇怪,但我没时间去修改网站了,直接在Delphi中加一个TWebbrowser,默认用ie7访问,效果还是不行。那么,怎么以ie11访问呢?查了半天,打到以下资料:

如果你是32位系统,访问:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

如果是64位系统,访问:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

但这个说得对吗?其实不对,我用的是64位的win10,但是也需要访问第一个注册表位置才行,找到位置以后怎么办?新建一个3位的DWORD类型,键名是你的程序名,比如说project1.exe,键值如下:

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.

把键值改成11001,还是不行,为什么?后来发现是微软的资料错了,0x2EDF对应的十进制不是11001而是11999!

改完以后,还是不行?怎么回事?再查资料,还需要修改HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

下对应的键值才行,这个网上的帖子也没说清楚,有的说修改HKEY_LOCAL_MACHINE即可,有的说HKEY_LOCAL_MACHINE和HKEY_CURRENT_USER二选一即可,我这机子上是必须同时修改才行,希望以后遇到类似问题的朋友可以少走点弯路。

你可能感兴趣的:(delphi,visual,studio,code)