How do I get two IWebBrowser2 objects to emulate different Internet Explorer versions?

741 views Asked by At

I'm working with an MFC application (C++). We use embedded browsers in some dialogs - IWebBrowser2 ActiveX objects. By default, they emulate IE version 7 (for compatibility reasons). We need a newer version to be able to display modern webpages, so we change IE version by setting the registry key FEATURE_BROWSER_EMULATION. (See this blogpost or other SO questions on the subject.)

But when we change to a newer IE for embedded browsers, a third party module we use crash. It turns out that it too uses a (hidden) IWebBrowser2 object, and it can't handle a modern IE. (Updating the third party module is not an option right now.)

The third party module isn't used often, so we tried solving it by changing the FEATURE_BROWSER_EMULATION temporary. But that doesn't work! It seems like FEATURE_BROWSER_EMULATION is only read the first time an IWebBrowser2 object is created. If you do like this:

 (1)  Set FEATURE_BROWSER_EMULATION to 7000 (=IE7)
 (2)  Create a dialog box with an IWebBrowser2 control (and navigate to "thismachine.info")
 (3)  Close the dialog box
 (4)  Set FEATURE_BROWSER_EMULATION to 11001 (=IE11)
 (5)  Create a dialog box with an IWebBrowser2 control (and navigate to "thismachine.info")

both IWebBrowser2 controls will be IE7! (If you swap 7000/11001 both will be IE11.) Despite that the whole dialog, the browser control and the first IWebBrowser2 object get deallocated in step (3).

Is there any way to get two IWebBrowser2 objects to use different IE versions in the same process? What's causing this - is there some "registry cache" in the COM handling, causing the new registry value to be ignored? (If so, is there a way to clear that cache?) Or is there some part of the first IWebBrowser2 object that isn't deallocated? (If so, is there a way to do that?) Or do anyone have a different approach/suggestion?

0

There are 0 answers