none
WebBrowser launches a 64-bit Internet Explorer from a 32-bit application

    Question

  • I have a 32bit application that hosts the WebBrowser control, that is navigated to a web site. When the page performs a window.open() call, WebBrowser launches a new Internet Explorer process (noting that NewWindow2 and NewWindow3 are not handled by my application).

    When this application runs (as 32bit) on Windows 7 64bit, the WebBrowser control launches a 64bit Internet Explorer process.

    My machine is setup (with standard IE defaults) having the 32bit Internet Explorer as the default (checked, double checked, etc).

    Now what is interesting is that Internet Explorer 32bit (which itself wraps around WebBrowser and MSHTML) in the same scenario, correctly launches a new 32bit process of IE. This implies that there is some mechanism to convince WebBrowser/MSHTML to create a 32bit instance, not a 64bit instance, but I cannot see how to achieve this.

    Unfortunately, the 64bit IE process is a problem because web pages love to use the Adobe Flash control (which has still not released a 64bit plugin).

    Does anyone know how I can convince WebBrowser/MSHTML to correctly launch a 32bit instance of IE? 

    Thanks,

     - B

    Friday, July 16, 2010 10:23 AM

Answers

  • The problem was submitted to Microsoft Premier Support. They have reproduced the problem and have suggested that an update will be released in the next couple of months (not 100% sure when).

    They suggested we try adding the following registry key to the 64bit machine in question:

       HKCR\Wow6432Node\CLSID\{D5E8041D-920F-45E9-B8FB-B1DEB82C6E5E}\LocalServer32

                REG_EXPAND_SZ                   "%programfiles(x86)%\Internet Explorer\iexplore.exe -startmediumtab"

    This then resolved the issue I was experiencing. The reg key in question has security on it, and to set it would require you taking ownership of the key first.

    It doesn't explain why if 32Bit IE is running, the new window is 32bit, and if no IE is running the new window is 64bit IE. It appears this workaround just forces the 32bit version to always load up if running from a 32bit process. This works perfectly for me, and would assume this is the correct assumption made for all 32bit applications running on a 64bit OS. It is similar to the suggestions provided here in the forums, but does not require me to hard-code a path to IE into my application (one day the path or EXE name could change).

    I do not know the exact nature of the planned fix (it could be as simple as setting the registry key), but that registry key provided a workaround that worked. However as an application running on the user's machine in non-elevated mode it was not something that could be considered for me.

    I patiently await the more permanent solution in the form of a hot-fix/automatic-update :)

    • Marked as answer by Beetle.Bailey Wednesday, September 08, 2010 1:18 PM
    Tuesday, September 07, 2010 11:10 AM

All replies

  • Hi Beetle,

    The key issue of launch a 32bit internet explorer is to find its absolute path. The 64bit one is usually in "C:\Program Files\Internet Explorer", but the 32bit one is in "C:\Program Files (x86)\Internet Explorer". Now we have the clue:

    1. We can add a application setting corresponding to IE path in the project of the application for which we will create a Setup Project. We can launch the correct IE based on this setting. 

    2. In the Setup Project we can check some properties to decide the version of the OS(32bit or 64bit) and write a custom action to change the application setting after it is installed.
    The related installer properties is: VersionNT64.
    The document below shows how to pass data to a custom action:
    http://msdn.microsoft.com/en-us/library/9cdb5eda(VS.71).aspx

    Let me know if this helps or not.
    Aland Li

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    Monday, July 19, 2010 5:48 AM
  • Here's something you could try, but it depends on WebBrowser finding iexplore.exe via the PATH environment variable, which I have no idea whether it does:

    When your executables starts (before doing any WebBrowser stuff), have it modify its PATH environment variable so that "C:\Program Files (x86)\Internet Explorer" is near the front.


    Answering policy: see profile.
    Monday, July 19, 2010 9:47 AM
  • I think the important point here is that I am not launching IE, but instead its part of the internals of the WebBrowser control (MSHTML). This is not an installer application, but rather a standalone application that happens to host an instance of the WebBrowser control.

    Forgive me if I have missed something completely (likely ;->), but I don't see how setting an Installer Property through a custom action would change how the WebBrowser Control (MSHTML) would internally handle a window.open() javascript call.

    I was hoping there is a registry setting, or a flag that is passed to the WebBrowser control that may control this. My last resort is to handle the OnNewWindow2 (or 3) event, decline it, and manually launch my own constructed instance of IE (but then I run the risk that I break some functionality that the web page has like enableing toolbars, setting window size, etc).

    - Brian

    Monday, July 19, 2010 10:58 AM
  • That seems a little hackish to be honest :). I am not 100% sure how the instance of Internet Explorer is being created. Is it done through a ShellExecute() on the URL, is it done through a CoCreateInstance() using the CLSID/PROGID etc?

    If its done via the CoCreateInstance() setting the path should have no impact.

    Monday, July 19, 2010 11:00 AM
  • Hi Beetle,

    Sorry for the mistake. I think the default brower setting in registry table decides which browser is launched when a URL needs to be opened. So there are two methods to sove the issue:

    1. Modify the registry setting related to default browser:
        1) Find HKEY_CLASSES_ROOT\http\shell\open\command and change its default value to the path of the 32bit internet explorer.
             In 64 bit machine, it is often "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
        2) Find HKEY_CLASSES_ROOT\http\shell\open\ddeexec\Application and change its default value to the browser name: "Internet Explorer".

    2. Handle the OnNewWindow2 event and call CreateProcess API to launch the URL with the 32bit internet explorer. Such as
           LPTSTR szCmdline[] = _tcsdup(TEXT("\"C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe\" http://www.test.com/test.aspx"));
           CreateProcess(NULL, szCmdline, /*...*/);
        You could get more about CreateProcess from:
           http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx

    To check if the operation system is 64 bit, we need to call the GetSystemInfo API and check SYSTEM_INFO.wProcessorArchitecture field. If its value is PROCESSOR_ARCHITECTURE_AMD64 or PROCESSOR_ARCHITECTURE_IA64, the system is a 64-bit operation system.
    Below are some related documents:
    http://msdn.microsoft.com/en-us/library/ms724381(VS.85).aspx
    http://msdn.microsoft.com/en-us/library/ms724958(VS.85).aspx
    http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx

    Let me know if this helps or not.
    Aland Li

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com

     


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    Tuesday, July 20, 2010 6:33 AM
  • Method 2 was the route I was planning on following as a last resort. If I approach this solution, how do I take care of the callers requests in terms of the size of the new window, and other settings such as toolbars, re-sizability, etc?

    I have also noticed, that if I have no instances of IE currently running, then the WebBrowser Control/MSHTML launches a 64bit version of IE on a "window.open()" call, however, if I have a 32bit version of IE running already (even if its blank), then the WebBrowser control launches a 32bit version of IE.

    I am not sure why a running instance of IE would make any difference, but it appears to be a significant factor in the symptoms.

    Tuesday, July 20, 2010 8:34 AM
  • Hi Beetle,

    What do you expect to launch when a new window event is fired, your application or a internet explorer?

    You said:  how do I take care of the callers requests in terms of the size of the new window, and other settings such as toolbars, re-sizability, etc?
    Where does the caller come from? If it comes from your application, it is better to open the new url via your application, not a new internet explorer process.

    Regards,
    Aland Li

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    Tuesday, July 20, 2010 9:08 AM
  • > What do you expect to launch when a new window event is fired, your application or a internet explorer?

    internet explorer. Specifically we expect that the page, hosted in IE, or our application, should behave the same way.

    > Where does the caller come from? If it comes from your application, it is better to open the new url via your application, not a new internet explorer process.

    The caller is "random javascript" on a webpage that the application has no control over or any expectations of. The web page is displayed using an "inproc" mshtml container to keep the web content in the same window but as soon as it launches any popups we (and the web design team I presume) expect it to simply "work" the same way, no matter what the initial host is.




    Tuesday, July 20, 2010 3:22 PM
  • In essence, my application is primarily focused on hosting the single page, and allowing it to navigate to sub pages, etc. Its has no intention of trying to manage tabs, or extra windows, and if the page that is being hosted decides to start a new window, a new instance of IE will satisfy the requirement of the hosted page.

    The hosted page is under our customers control, not the developers (aka me). The customer decides what the user will see, and under some (admittedly few) conditions, they want a new popup window to be created.

    The concern is really that in general, why would the 32bit WebBrowser/MSHTML control launch a 64bit instance of IE, when:

    1. It is a 32bit instance of the control to start off with,
    2. Internet Explorer (32bit) is the default application (and the default browser),
    3. and why would a running copy of 32bit IE make a difference to the decision

    In an earlier reply I mentioned that if I have any instance of 32bit IE running on the machine at the time, the new window is "correctly" instantiated in a 32bit IE. It only loads a 64bit instance of IE if there are no 32bit instances of IE running.

    Thanks for your responses so far, I really appreciate the help.

    Tuesday, July 20, 2010 4:20 PM
  • First of all, I think the below code will create a 32bit IE instance.

    ---------------------------------------

    BOOL OpenNewWindowEx(LPCTSTR pAddress, BOOL bMenu, BOOL bToolBar,
             BOOL bAddressBar, BOOL bStatusBar, BOOL bResize,
             int x, int y, int cx, int cy)
    {
     CoInitialize(NULL);
     IWebBrowser2 *pWebBrowser;
     HRESULT hr;
     
     hr = ::CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
      IID_IWebBrowser2, (void**)&pWebBrowser);
     if(FAILED(hr) || pWebBrowser == NULL) return FALSE;
     
     pWebBrowser->put_MenuBar(bMenu ? VARIANT_TRUE : VARIANT_FALSE);
     pWebBrowser->put_ToolBar(bToolBar ? VARIANT_TRUE : VARIANT_FALSE);
     pWebBrowser->put_AddressBar(bAddressBar ? VARIANT_TRUE : VARIANT_FALSE);
     pWebBrowser->put_StatusBar(bStatusBar ? VARIANT_TRUE : VARIANT_FALSE);
     pWebBrowser->put_Resizable(bResize ? VARIANT_TRUE : VARIANT_FALSE);
     
     if(x >= 0) pWebBrowser->put_Left(x);
     if(y >= 0) pWebBrowser->put_Top(y);
     if(cx >= 0) pWebBrowser->put_Width(cx);
     if(cy >= 0) pWebBrowser->put_Height(cy);
     
     CString strAddress = pAddress;
     
     VARIANT vtFlags, vtTarget, vtPostData, vtHeader;
     ::VariantInit(&vtFlags);
     ::VariantInit(&vtTarget);
     ::VariantInit(&vtPostData);
     ::VariantInit(&vtHeader);
     
     pWebBrowser->put_Visible(VARIANT_TRUE);
     hr = pWebBrowser->Navigate(strAddress.AllocSysString(), &vtFlags, &vtTarget,
      &vtPostData, &vtHeader);
     if(FAILED(hr)) return FALSE;
     
     pWebBrowser->Release();
     CoUninitialize();
     
     return SUCCEEDED(hr);
    }

    ------------------------------------

    And then, the reason why 32 bit IE makes an instance of 64bit IE is that it just makes a new instance of IE like ShellExecute function does.

    Thus, if you want to change the behavior, you should change the registry settings of custmers'. However, it might be a bad solution if your users are sensative about changing their computer settings.

    Since it is not a good solution, I suggest that you could handle almost every events which will make a new instance of IE by handling OnBeforeNavigate serieses and OnNewWindow serieses.


    Realization of Dream
    Wednesday, July 21, 2010 12:35 AM
  • Hi Beetle,

    Could you please let me know if it makes sense if the default browser setting is set via registry table?

    Regards,
    Aland Li

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
    Wednesday, July 21, 2010 7:50 AM
  • Hi Beetle.

     

    I have a exactly same problem.

    have you solved the problem?

    if you have solved, please help.

     

    Thanks.

    Tuesday, September 07, 2010 5:13 AM
  • The problem was submitted to Microsoft Premier Support. They have reproduced the problem and have suggested that an update will be released in the next couple of months (not 100% sure when).

    They suggested we try adding the following registry key to the 64bit machine in question:

       HKCR\Wow6432Node\CLSID\{D5E8041D-920F-45E9-B8FB-B1DEB82C6E5E}\LocalServer32

                REG_EXPAND_SZ                   "%programfiles(x86)%\Internet Explorer\iexplore.exe -startmediumtab"

    This then resolved the issue I was experiencing. The reg key in question has security on it, and to set it would require you taking ownership of the key first.

    It doesn't explain why if 32Bit IE is running, the new window is 32bit, and if no IE is running the new window is 64bit IE. It appears this workaround just forces the 32bit version to always load up if running from a 32bit process. This works perfectly for me, and would assume this is the correct assumption made for all 32bit applications running on a 64bit OS. It is similar to the suggestions provided here in the forums, but does not require me to hard-code a path to IE into my application (one day the path or EXE name could change).

    I do not know the exact nature of the planned fix (it could be as simple as setting the registry key), but that registry key provided a workaround that worked. However as an application running on the user's machine in non-elevated mode it was not something that could be considered for me.

    I patiently await the more permanent solution in the form of a hot-fix/automatic-update :)

    • Marked as answer by Beetle.Bailey Wednesday, September 08, 2010 1:18 PM
    Tuesday, September 07, 2010 11:10 AM
  • Hi Bailey,

    It seems I got the same problem with IECapt.exe tool. It automatically runs IE 64bits, then can not load flash to capture.

    Follow your suggestion, I should add a new key to "HKCR\Wow6432Node\CLSID\{D5E8041D-920F-45E9-B8FB-B1DEB82C6E5E}\LocalServer32". But in you post, I can only see its Type and Data (REG_EXPAND_SZ "%programfiles(x86)%\Internet Explorer\iexplore.exe)-startmediumtab"). How can I enter the key's Name?

    Thanks a lot.

    Best Regards,

     

    Thursday, September 16, 2010 7:18 AM
  • Hi, Bailey,

    I have entered the key with no name, and it doesn't seem to work.  If you can give us the key name I would appreciate it very much. 

    Thanks,

    Jeffrey

    Wednesday, October 06, 2010 7:13 PM
  • Hi, Beetle,

    Just want to know the name of the added key above? It seems without the key name it doesn't work (still get IE8 64-bit launched from the WebBrowswer control).

    Thanks,

    Wednesday, October 06, 2010 9:01 PM
  • It appears that the official fix has been released:

     

    A hyperlink that is specified to open in a 32-bit instance of Internet Explorer 8 opens in a 64-bit instance of Internet Explorer 8

    http://support.microsoft.com/kb/2310259

     

    The registry fix is indeed documented in the support article as one of the workarounds:

    Method 2

    Modify the HKEY_CLASSES_ROOT registry hive to add the missing handler for theInternetExplorerMedium CLSID. To do this, type the following command at a command prompt and then press ENTER:
    Reg add "HKCR\Wow6432Node\CLSID\{D5E8041D-920F-45E9-B8FB-B1DEB82C6E5E}\LocalServer32" /ve /t REG_EXPAND_SZ /d "%programfiles(x86)%\Internet Explorer\iexplore.exe -startmediumtab"

    Wednesday, November 10, 2010 12:18 AM
  • Follow your suggestion, I should add a new key to "HKCR\Wow6432Node\CLSID\{D5E8041D-920F-45E9-B8FB-B1DEB82C6E5E}\LocalServer32". But in you post, I can only see its Type and Data (REG_EXPAND_SZ "%programfiles(x86)%\Internet Explorer\iexplore.exe)-startmediumtab"). How can I enter the key's Name?

    Based on the information provided by youngloc in this thread, the Key name is LocalServer32 and the value name is the empty (Default) value name [ deduced from use of /ve flag to reg.exe ].
    Answering policy: see profile.
    Wednesday, November 10, 2010 11:09 AM
  • Brian--

     

    I had the same problem and it turned out that not all of the projects in my solution were set to compile on an x86 platform?  It HAD been set correctly prior to now, but somehow the  platforms were reset to any CPU.

     

    --Seth

    Friday, January 21, 2011 4:42 PM
  • I had a similar issue were neither Flash, nor Silverlight would work and I found out that it was always launching 64-bit browser when it opened new pages, even if you had first opened iexplore.exe 32-bit version manually

    Based on the above discussion, I used IE's Internet Options / Advanced dialog and pressed the "Restore settings" button and didn't select to delete personal data (just reset the settings as is the default there) and all was fixed


    Microsoft MVP J# 2004-2010, Borland Spirit of Delphi 2001

    Monday, November 18, 2013 2:22 PM