Getting the History from Internet Explorer



Click here for a larger image.

Environment: VC6

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 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;
  }
]

Downloads

Download demo project - 28 Kb
Download source - 11 Kb


Comments

  • This code does not show all history

    Posted by Yuri.Gubanov on 06/24/2006 04:34pm

    I run the sample on my computer where IE options set to store history for 150 days. Only latest 3 days were shown although IE itself shows much more history (up to 21 weeks).

    Reply
  • CoCreateInstance failed?

    Posted by linfeng1216 on 03/08/2004 07:53am

    CoCreateInstance failed?

    Reply
  • something useful~ but win2000 & ie5.5 are needed at least in the app.

    Posted by Legacy on 11/19/2003 12:00am

    Originally posted by: gothica

    STATURL is minimum available for IE5.5 and Win2000.
    Can Mr.Akash tell me how to do in win9x,ie5.0 ...?
    my email:allenhooo@sina.com, thanks a lot!

    Reply
  • Show history for ALL users?

    Posted by Legacy on 09/05/2003 12:00am

    Originally posted by: Jeff

    If there are many users using my computer, how can I get the history for each one of the users? Assuming I have Administrator access...

    Thanks for the article!!!

    Reply
  • AfxOleInit() unsuccessful, return 0

    Posted by Legacy on 06/23/2003 12:00am

    Originally posted by: shawn

    AfxOleInit() unsuccessful, return 0

    Reply
  • not compile?

    Posted by Legacy on 01/03/2003 12:00am

    Originally posted by: mohad

    istoryDisplay.cpp
    c:\program files\microsoft visual studio\vc98\include\mshtml.h(16768) : error C2367: 'IHTMLControlElement' : redefinition; different uuid specifiers
    c:\program files\microsoft visual studio\vc98\include\mshtml.h(16768) : see declaration of 'IHTMLControlElement'
    HistoryDisplayDlg.cpp
    c:\program files\microsoft visual studio\vc98\include\mshtml.h(16768) : error C2367: 'IHTMLControlElement' : redefinition; different uuid specifiers
    c:\program files\microsoft visual studio\vc98\include\mshtml.h(16768) : see declaration of 'IHTMLControlElement'
    HistoryListCtrl.cpp
    c:\program files\microsoft visual studio\vc98\include\mshtml.h(16768) : error C2367: 'IHTMLControlElement' : redefinition; different uuid specifiers
    c:\program files\microsoft visual studio\vc98\include\mshtml.h(16768) : see declaration of 'IHTMLControlElement'
    ListControlItem.cpp
    Generating Code...
    Error executing cl.exe.

    HistoryDisplay.exe - 3 error(s), 0 warning(s)


    what's going on here?
    Thank you so much!
    ~~mohad

    Reply
  • Memory Leak.

    Posted by Legacy on 12/17/2002 12:00am

    Originally posted by: Adam Choison

    The sample code has memory leak bug.
    
    Add these lines your code.


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

    // BUG FIX !!!
    // Add follows
    if (url.pwcsUrl != NULL)
    CoTaskMemFree(url.pwcsUrl);
    if (url.pwcsTitle != NULL)
    CoTaskMemFree(url.pwcsTitle);
    }

    Reply
  • Object failed to create

    Posted by Legacy on 10/18/2002 12:00am

    Originally posted by: Toby

    I tried out this code but the object is not being created.. the value being returned by CoCreateInstance is "-2147221008" (2147746288 unsigned), which doesn't map to one of the return codes listed under MSDN.

    I checked the registry and the CLSID entries for both IUrlHistoryStg and IUrlHistoryStg2 are there... what do I need to do to get this to work??

    Thanks
    Toby


    Reply
  • excellent

    Posted by Legacy on 10/03/2002 12:00am

    Originally posted by: roshan

    i found it excellent

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

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds