Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Access Internet Explorer's History in MFC

0.00/5 (No votes)
14 Aug 2004 1  
Getting the History from Internet Explorer in MFC.

Sample Image - iehistory.gif

Introduction

I just wanted to access the history of Internet Explorer. I found no code anywhere to get it directly, but somehow I managed to combine some of the code and get this working application. The code isn't very great, but it is somewhat useful, you can say. I am not a great writer, so don't expect a good explanation. My coding style is self-explanatory. If you open the IEHistory.h file, you will get to see everything.

[
  #include <atlbase.h>

  #include <comdef.h>

  #include <mshtml.h>

  #include <UrlHist.h>

  #include <afxtempl.h>


  BOOL  GetHistory(CStringList & list)
  {
    STATURL url;
    CString strUrl;
    ULONG uFetched;
    IUrlHistoryStg2Ptr history;
    IEnumSTATURLPtr enumPtr;

    if(FAILED(CoCreateInstance(CLSID_CUrlHistory,
          NULL,
          CLSCTX_INPROC_SERVER,
          IID_IUrlHistoryStg2,
          ( void**)&history)))
          {
            return false ;
          }

          if(FAILED(history->EnumUrls(&enumPtr)))
      return false;

    while(SUCCEEDED(enumPtr->Next(1,&url,&uFetched)))
    {
      if(uFetched==0)
        break;
      strUrl = url.pwcsUrl;
      list.AddTail(strUrl);
    }
    return true;
  }
]

More about me.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here