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

More by Author

Previous articleDetect if window is split
Next articleCOM+ in .NET

Must Read