Click here to Skip to main content
15,918,109 members
Articles / Desktop Programming / ATL
Article

Access Internet Explorer's History in MFC

Rate me:
Please Sign up or sign in to vote.
4.63/5 (5 votes)
14 Aug 2004CPOL 50.8K   2.1K   23   5
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Programmer with WILL

Comments and Discussions

 
QuestionHi, I am getting history of all the browsers, How to limit data to only Internet explorer and display only Internet explorer Data Pin
Member 1171467521-Jun-21 8:07
Member 1171467521-Jun-21 8:07 
QuestionI am not able to compile the project ... Pin
Saikat_EPAM27-Apr-21 3:02
Saikat_EPAM27-Apr-21 3:02 
QuestionHow can I compile ..... Pin
junyoungkyun21-Jun-05 6:31
junyoungkyun21-Jun-05 6:31 
AnswerRe: How can I compile ..... Pin
cydst27-Nov-07 17:09
cydst27-Nov-07 17:09 
GeneralFreeing the returned strings Pin
Robert Hastings28-Oct-04 7:25
Robert Hastings28-Oct-04 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.