How to obtain and clear ie history records

Source: Internet
Author: User
Tags filetime
I. Mainly use the interface implementation provided by the COM component. Several interfaces include:
1. iurlhistorystg and iurlhistorystg2 (iurlhistorystg2 interface inherited from iurlhistorystg)
2. ienumstaturl
The following interface information is taken from msdn
Iurlhistorystg Interface

This interface manages Microsoft Internet Explorer history for the current user.

Iurlhistorystg members

Addurl Places the specified URL into the history. If the URL does not exist in the history, an entry is created in the history. If the URL does exist in the history, it is overwritten.
Bindtoobject Not currently implemented.
Deleteurl Deletes all instances of the specified URL from the history.
Enumurls Returns an interface to an enumerator of the history's visited links.
Queryurl Queries the history and reports whether the URL passed asPocsurlParameter has been visited by the current user.

Interface Information

Stock implementation Shdocvw. dll
Custom implementation No
Inherits from Iunknown
Header and IDL files Urlhist. H, urlhist. IDL
Minimum availability Internet Explorer 5.5
Minimum Operating Systems Millennium, Windows 2000

Iurlhistorystg2 Interface

This interface provides additional features for managing the user's history.

Iurlhistorystg2 members

Addurlandnotify Provides an advanced method of adding a URL to the history.
Clearhistory Clears history on a per-user basis.

Interface Information

Stock implementation Shdocvw. dll
Custom implementation No
Inherits from Iurlhistorystg
Header and IDL files Urlhist. H, urlhist. IDL
Minimum availability Internet Explorer 5.5
Minimum Operating Systems Millennium, Windows 2000

Ienumstaturl Interface

This interface enumerates the items in the History cache.

Ienumstaturl members

Clone Not currently implemented.
Next Searches the history for any URL that matches the search pattern and copies it to the specified buffer.
Reset Resets the enumerator interface so that it begins enumerating at the beginning of the history.
Setfilter Ienumstaturl: Next compares the specified URL with each URL in the History list to find matches.Ienumstaturl: NextThen copies the list of matches to a buffer. This method is used to specify the URL to compare.
Skip Not currently implemented.

Interface Information

Stock implementation Shdocvw. dll
Custom implementation No
Inherits from Iunknown
Header and IDL files Urlhist. H, urlhist. IDL
Minimum availability Internet Explorer 5.5
Minimum Operating Systems Millennium, Windows 2000

2. Related methods in the interfaces used:
1. iurlhistorystg: enumurls

Iurlhistorystg: enumurls Method
Returns an interface to an enumerator of the history's visited links.
Syntax
Hresult enumurls (ienumstaturl ** ppenum );
Parameters
Ppenum: [out] pointer that sums es a pointer to the interface to a history enumerator.
Return Value
Returns s_ OK if successful, or an error value otherwise.

2. ienumstaturl: Next

Lresult ienumstaturl: Next (ulong Celt, lpstaturl rgelt, ulong * pceltfetched)
Parameter description:
Celt is of unknown significance and cannot be 0. You can set it to 1.
Rgelt is a staturl structure pointer that is filled with a MS-IE.
Pceltfetched is returned by the method. If the return value is 1, The rgelt structure is successfully filled. To use the data in the second parameter, you should determine whether the value is 1.

The structure staturl is defined as follows:

Staturl Structure
Contains statistics about a URL. This structure is filled by Microsoft Internet Explorer during callto iurlhistorystg: queryurl and ienumstaturl: Next.

Syntax

Typedef struct _ staturl ...{
DWORD cbsize;
Lpwstr pwcsurl;
Lpwstr pwcstitle;
Filetime ftlastvisited;
Filetime ftlastupdated;
Filetime ftexpires;
DWORD dwflags;
} Staturl, * lpstaturl;

Members

Cbsize
DWORD that shoshould be set to sizeof (staturl ).
Pwcsurl
The specified URL. The calling function must free this parameter. Set this parameter to staturl_queryflag_nourl if no URL is specified.
Pwcstitle
The title of the web page, as contained in the title tags. This calling application must free this parameter. Set this parameter to staturl_queryflag_notitle if no web page is specified.
Ftlastvisited
The last time the user visited this page.
Ftlastupdated
The last time the page was updated.
Ftexpires
The expiry date of the web page's content.
Dwflags
DWORD that can be either staturl_queryflag_iscached or staturl_queryflag_toplevel.

Iii. Code Implementation (vc6.0 + Windows XP) 

# Include <stdio. h>
# Include <windows. h>
# Include <urlhist. h> // iurlhistorystg2
# Include <shlobj. h> // clsid_curlhistory, shaddtorecentdocs
# Include <atlbase. h> // uses_conversion;

Void getiehistory ()
......{
Uses_conversion; // Unicode to ANSI
Coinitialize (null); // Initialization

Iurlhistorystg2 * purlhistorystg2 = NULL;
Hresult hR = cocreateinstance (clsid_curlhistory,
Null, clsctx_inproc, iid_iurlhistorystg2,
(Void **) & purlhistorystg2 );

/** // */* If (succeeded (HR ))
{
HR = purlhistorystg2-> clearhistory ();
Purlhistorystg2-> release ();
}*/

Ienumstaturl * penumurl;
HR = purlhistorystg2-> enumurls (& penumurl );

Staturl suurl;
Ulong pceltfetched;
Suurl. cbsize = sizeof (suurl );
HR = penumurl-> Reset ();

While (hR = penumurl-> next (1, & suurl, & pceltfetched) = s_ OK)
......{
// HR = purlhistorystg2-> deleteurl (suurl. pwcsurl, 0 );
Printf ("% s", w2t (suurl. pwcsurl ));
}

Penumurl-> release ();
Purlhistorystg2-> release ();
Couninitialize ();
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.