I am looking at creating a small app which will gain access to and use the Internet Explorer DOM.
I want to access the DOM of an existing instance of Internet Explorer.

The app will be basic and simple, and will be first used to retieve properties of web page elements.

My questions are, where do I start, what functions API's should I be looking at, bearing in mind that I intend to stay within the bounds of WIN32 (that is, if COM can be used within those bounds).

My initial search was quite poor because of not knowing what API's/functions I'm looking for.

I appreciate your reading and am greatful for any help you can offer to get me started.

Edited by Suzie999

3 Years
Discussion Span
Last Post by Suzie999

I have made a little headway after finding CoCreateInstance function, but hit a problem quickly.
I'm hoping someone might give me a nudge regarding my mistake.

void MgBx(char * title, DWORD error = 0){

    char serror [11];
    _ultoa_s(error, serror, sizeof(serror), 10);

    MessageBoxA(NULL, serror, title, MB_OK);
    if (error) {

int _tmain(int argc, _TCHAR* argv[])
    HRESULT coinit = CoInitializeEx(
    if(coinit != S_OK){
        MgBx("Error - CoInitialize\0", GetLastError());

    CLSID clsid;
    HRESULT clsidfromprogid = CLSIDFromProgID(
    if(clsidfromprogid != S_OK){
        MgBx("Error - clsidfromprogid\0", GetLastError());

    IDispatch *idispatch = NULL;
    HRESULT Obj = CoCreateInstance(
        (LPVOID *)&idispatch);
    if(Obj != S_OK){
        MgBx("Error - CoCreateInstance\0", GetLastError());

    return 0;

Result is Error - CoCreateInstance:
error 14007 (ERROR_SXS_KEY_NOT_FOUND) The requested lookup key was not found in any active activation context.

I have no Idea what that means.

Edited by Suzie999


It certainly helps to know which APIs to search for. You can find out what interfaces an application exports with Microsoft's OleView, or some other COM viewer.

Although the utility was removed from VS2010, the source code can be found in the VS samples directory:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Samples\1033\VC2010Samples.zip

A compiled version can also be found in the Windows SDK, available from MS.

Edited by LaxLoafer


I've gotten to the point where I can create a new instance of Internet Explorer and navigate to an address, but not much else.

"clsidfromprogid()" with "InternetExplorer.Application" Appeared to be no good, and needed substituting ith "IWebBrowser2"

Still however stuck on attaching to a running instance of IE.
I believe it has something to do (again) with "InternetExplorer.Application", where I should be using "Shell.Application"and getting access to its interface somehow.

I tried with the working code to navigate via existing instance with a VARIANT flag of idispatch->Navigate() set to navBrowserBar, which does not work, and will only work with that flag set to navOpenInNewWindow.

I'm getting a little dizzy with it all, and calling it a night. Maybe fresh morning me can do a little better.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.