Virtual Developer Workshop: Containerized Development with Docker

Environment: ****** -->

There are some methods to connect to a running instance of IE. This one is how to connect through the ROT (Running Object Table).

Usually, an application connects to a running instance of another application using the Running Object table. However the Internet Explorer 4.0 doesn't not register itself in ROT. The solution is to write so-called "Browser Helper Object" – a tiny COM object that exposes IObjectWithSite interface and register itself in the ROT. Also it's necessary to register this object in the Registry under the following key:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\ 
The Internet Explorer will create new instance of each Browser Helper Object listed in registry every time new instance of Internet Expoler is started.
       \CurrentVersion\Explorer\Browser Helper Objects\{CE7C3CF0-4B15- 11D1-ABED-709549C10000} 

The following code demonstrates how to allow multiple instances of the Internet Explorer to be registered in the ROT using item moniker.
/////////////////////////////////////////////////////////////////////////////  IEHELPER.H
#ifndef __IEHELPER_H_
#define __IEHELPER_H_

#include "resource.h"       // main symbols

// CIEHelper
class CIEHelper : 
        public CComObjectRootEx<CComSingleThreadModel>,
        public CComCoClass<CIEHelper, &CLSID_IEHelper>,
        public IObjectWithSiteImpl<CIEHelper>,
        public IIEHelper
                m_dwROTID = 0;


        // IObjectWithSite interface
        STDMETHOD(SetSite)(IUnknown* pUnkSite);



// IIEHelper
        void SetROTID(DWORD dwValue)
                m_dwROTID = dwValue;
        DWORD m_dwROTID;
        void ROT_UnRegister();
        void ROT_Register();

#endif //__IEHELPER_H_

/////////////////////////////////////////////////////////////////// IEHELPER.CPP
// IEHelper.cpp : Implementation of CIEHelper

#include "stdafx.h"
#include "IE.h"
#include "IEHelper.h"

#include <initguid.h>
#include <exdisp.h>        // the IID_IWebBrowser is located over there
#include <stdio.h>

// CIEHelper

// CObjectWithSite Methods

STDMETHODIMP CIEHelper::SetSite(IUnknown* pUnkSite)

        // remove previously registered object from the table

        // neccessary initialization
        HRESULT hResult = IObjectWithSiteImpl<CIEHelper>::SetSite(pUnkSite);

        // register helper object in the running object table

        return hResult;


// Private Section

const static TCHAR* szMonikerTemplateName = _T("Browser Helper Object");

// register the object in the running object table 

void CIEHelper::ROT_Register()
        CComPtr<IRunningObjectTable> pTable;
        if(GetRunningObjectTable(0, &pTable) == S_OK)
                CComBSTR bstrItemName;
                CComPtr<IMoniker> pMoniker;
                TCHAR szBuffer[1024];

                sprintf(szBuffer, "%s | %d", szMonikerTemplateName, m_spUnkSite);
                bstrItemName = szBuffer;
                if(CreateItemMoniker(NULL, bstrItemName, &pMoniker) == S_OK)
                        DWORD dwRegister;
                        if(pTable->Register(1, (IUnknown*)this, pMoniker, &dwRegister) == S_OK)
                                ATLTRACE("IIEHelper: the moniker %s has been registered successfully\n", szBuffer);
                                ATLTRACE("IIEHelper: failed to register moniker % s in the ROT\n", szBuffer);
                        ATLTRACE("IIEHelper: failed to create moniker %s\n", szBuffer);
                ATLTRACE("IIEHelper: Could not retrieve the ROT pointer\n");

void CIEHelper::ROT_UnRegister()
        CComPtr<IRunningObjectTable> pTable;
        if(GetRunningObjectTable(0, &pTable) == S_OK)
                HRESULT hRes = pTable->Revoke(m_dwROTID);
                ATLTRACE("IIEHelper: ID = %d, result code %x\n", m_dwROTID, hRes);

////////////////////////////////////////////////////////////////////// IEHELPER.RGS
// The following lines should be included into the self-registration portion of 
// COM application.


                                                'Browser Helper Objects'

Having implemented and registered the Browser Helper, an application can now obtain the pointer to a running instance of IE by traversing the ROT.

The following example shows the rough method I used to list the instances of IE:

IRunningObjectTable* pTable;

if(!FAILED(GetRunningObjectTable(0, &pTable)))
        IEnumMoniker* pEnum;
                IUnknown* pUnknown;
                IMoniker* pCurMoniker = NULL;
                LPMALLOC pMalloc;
                while (pEnum->Next(1, &pCurMoniker, NULL) == S_OK) 
                        if(!FAILED(pTable->GetObject(pCurMoniker, &pUnknown)))
                                IObjectWithSite* pSite;
                                if(!FAILED(pUnknown->QueryInterface(IID_IObjectWithSite, (void**)&pSite)))
                                        IDispatch* pDispatch;
                                        if(pSite->GetSite(IID_IDispatch, (void**)&pDispatch) == S_OK)
                                                CWebBrowserApp browser;
                                                TRACE("LocationURL: %s\n", browser.GetLocationURL());
                                                        TRACE("LocationName: %s\n", browser.GetLocationName());


The following file is available for download from the Microsoft Software Library:

 ~ IEHelper.exe (size: 39958 bytes) 


  • How to capture packet information in a data stream?

    Posted by Legacy on 08/14/2003 07:00am

    Originally posted by: Srinivas Divi

    Hi All,

    Its no doubt that data transmission through internet is via packets. Is there any way to capture the data, packet by packet? My purpose is to capture each and every data packet to do some processing. How can I do that? Any suggestions and locations where I cant get enough information are welcome.

    Thanks in advance !!


  • HOWTO: Stop pop-up ads w/BHO.

    Posted by Legacy on 07/03/2003 07:00am

    Originally posted by: BurningBunny

    1. Look at Peter's example of how to use his code.

    2. Notice the statement: "CWebBrowserApp browser;".

    3. "CWebBrowserApp" refers to a "IWebBrowser2" interface.

    4. Look up "IWebBrowser2" on MSDN and browse it's members.

    5. Almost all pop-ups can not be resized.

    6. "IWebBrowser2" has a member called "Resizable".

    7. Assume all non-resizable windows are pop-ups.

    8. Close suspected pop-ups with the "Quit" member.

    9. Code to add to Peters example:
    (Insert after "browser.AttachDispatch(pDispatch);", line 23)

    /* Begin Code Snip */
    // browser.AttachDispatch(pDispatch);

    BOOL bResizable;
    if(browser.GetResizable(&bResizable) == S_OK) {
    if(bResizable == VARIANT_FALSE) {
    browser.Stop(); // Stop loading the page.
    broswer.Quit(); // Close the window.

    // browser.DetachDispatch();
    // pDispatch->Release();
    // }
    /* End Code Snip */

    10. If your experienced enough to build the COM object, you should be able to impliment this code.

    11. Please, DO NOT email me asking how to do something.


  • How to create a Internet Explorer Plugin

    Posted by Legacy on 10/07/2002 07:00am

    Originally posted by: Joe

    Hi all,

    how can I create my own IE plugin like Flash?...


  • Internet Programming Problem with registerasDropTarget

    Posted by Legacy on 08/23/2002 07:00am

    Originally posted by: Rupankar

    I need a serious help.I have written an activex control which changes the default drop behaviour of IE in which my control is loaded.For this I am Using the shodocvw.dll and finding all running instances of IE and from the UserControl parent property I am determining the IE instance which has the activeX loaded.After determining I am changing the RegisterasDropTarget property to False(at Run Time).All this is done in the UserControl show event.How ever there is a serious problem.After opening the html page in IE if i drop a .txt file in the browser (then the browser is opening it).This is the default behaviour of IE which i want to Override.Then if I click back and then again drop the .txt file then I see that the default behaviour is overridden (as expected).Amazingly If I load the same html file in a WEbBrowser Control inside a VB form and change the RegisterasDropTarget property to false(design time) then it is working perfectly from the beginning.

    Can Anybody help me get a solution on this.I cannot proceed further with my ActiveX Control before resolving this bug.

    Thanks and Regards


    • Internet programming problem

      Posted by agrawvis on 11/23/2006 08:33pm

      I have a similar kind of problem, I want to execute some javascript on my webpage when , the dragged object is dropped on the browser window. The object can be dragged from filesystem/desktop and dropped in the browser. Instead of opening the object in the browser, we need to execute the javascript.
      If you have the solution please reply(agrawvis@gmail.com)

  • How to detect embeded IE/MSHTML Secessions?

    Posted by Legacy on 06/06/2002 07:00am

    Originally posted by: nnoydb

    My question isn't simple I have spend some time attempting to locate a answer but have found little or no information. I would like to know how to "listen"/"snoop" on applications using a embedded IE window/MSHTML control. These application have implemented their own "window" or frame in a MDI application that acts as a browser gateway. A exmple of such a application is the MSDN Library application.


  • How can I verify that a connection is on without creating one?

    Posted by Legacy on 01/22/2002 08:00am

    Originally posted by: Larsson

    Please help me with this sombody, I need it to work like this but I need to now is the computer is connected to the internet!


  • How to write a plug-in for internet explorer?

    Posted by Legacy on 10/30/2001 08:00am

    Originally posted by: Hemakumar

    Hello !
    My name is Sasha Kroch.
    if you write plugin for Internet Explorer please
    write me how did you do it.

  • How can I verify that a connection is on without creating one?

    Posted by Legacy on 10/09/2001 07:00am

    Originally posted by: Oren Farber


    I create a connection using CSocket the problem is that the Create method cause the Dial-up dialog to appear. Is there any way to verify that the computer is already connected?


  • this

    Posted by Legacy on 09/14/2001 07:00am

    Originally posted by: New comer

    How can i redirect to another URL when user types some blocked URL

  • What is CWebBrowserApp class?

    Posted by Legacy on 08/25/2001 07:00am

    Originally posted by: Murugan

    Can anyone let me know what is the definition of the class CWebBrowserApp which have been used in this
    class and what is its functionality ?

    Thanks in Advance

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date