如何获取与清除IE历史记录
来源:互联网 发布:财新网数据新闻 编辑:程序博客网 时间:2024/05/22 08:02
一、 主要用到了COM组件提供的接口实现,几个接口包括:
1、IUrlHistoryStg、IUrlHistoryStg2(IUrlHistoryStg2接口继承自IUrlHistoryStg)
2、IEnumSTATURL
下面接口信息摘自MSDN
IUrlHistoryStg InterfaceIUrlHistoryStg2 Interface
IEnumSTATURL Interface
1、IUrlHistoryStg、IUrlHistoryStg2(IUrlHistoryStg2接口继承自IUrlHistoryStg)
2、IEnumSTATURL
下面接口信息摘自MSDN
IUrlHistoryStg Interface
This interface manages Microsoft Internet Explorer history for the current user.
IUrlHistoryStg Members
AddUrlPlaces 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.BindToObjectNot currently implemented.DeleteUrlDeletes all instances of the specified URL from the history.EnumUrlsReturns an interface to an enumerator of the history's visited links.QueryUrlQueries the history and reports whether the URL passed as the pocsUrlparameter has been visited by the current user.
Interface Information
Stock Implementation shdocvw.dllCustom Implementation NoInherits from IUnknownHeader and IDL files urlhist.h, urlhist.idlMinimum availability Internet Explorer 5.5Minimum operating systems Millennium, Windows 2000
This interface provides additional features for managing the user's history.
IUrlHistoryStg2 Members
AddUrlAndNotifyProvides an advanced method of adding a URL to the history.ClearHistoryClears history on a per-user basis.
Interface Information
Stock Implementation shdocvw.dllCustom Implementation NoInherits from IUrlHistoryStgHeader and IDL files urlhist.h, urlhist.idlMinimum availability Internet Explorer 5.5Minimum operating systems Millennium, Windows 2000
This interface enumerates the items in the history cache.
IEnumSTATURL Members
CloneNot currently implemented.NextSearches the history for any URL that matches the search pattern and copies it to the specified buffer.ResetResets the enumerator interface so that it begins enumerating at the beginning of the history.SetFilterIEnumSTATURL::Next compares the specified URL with each URL in the history list to find matches. IEnumSTATURL::Next then copies the list of matches to a buffer. This method is used to specify the URL to compare.SkipNot currently implemented.
Interface Information
Stock Implementation shdocvw.dllCustom Implementation NoInherits from IUnknownHeader and IDL files urlhist.h, urlhist.idlMinimum availability Internet Explorer 5.5Minimum operating systems Millennium, Windows 2000
二、用到的接口中的相关方法:
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 receives a pointer to the interface to a history enumerator.
Return Value
Returns S_OK if successful, or an error value otherwise.
Returns an interface to an enumerator of the history's visited links.
Syntax
HRESULT EnumUrls( IEnumSTATURL **ppEnum);
Parameters
ppEnum :[out] Pointer that receives 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)
参数说明:
celt 意义不明,不能为0,可以将其设为1。
Rgelt 是STATURL结构指针,该结构由MS-IE填充。
PceltFetched 由方法返回,返回1表示rgelt结构被成功填充了。若要用到第二参数内的数据,应该判断该值是否为1。
参数说明:
celt 意义不明,不能为0,可以将其设为1。
Rgelt 是STATURL结构指针,该结构由MS-IE填充。
PceltFetched 由方法返回,返回1表示rgelt结构被成功填充了。若要用到第二参数内的数据,应该判断该值是否为1。
其中结构STATURL定义如下
STATURL Structure
Contains statistics about a URL. This structure is filled by Microsoft Internet Explorer during calls to 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 should 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.
Contains statistics about a URL. This structure is filled by Microsoft Internet Explorer during calls to 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 should 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.
三、代码实现(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转Ansi用
CoInitialize(NULL); //初始化
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();
}
#include <windows.h>
#include <UrlHist.h> // IUrlHistoryStg2
#include <shlobj.h> // CLSID_CUrlHistory, SHAddToRecentDocs
#include <atlbase.h> // USES_CONVERSION;
void GetIEHistory()
...{
USES_CONVERSION;//Unicode转Ansi用
CoInitialize(NULL); //初始化
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();
}
- 如何获取与清除IE历史记录
- 如何获取与清除IE历史记录
- 如何得到IE的历史记录和清除IE的历史记录
- 如何得到IE的历史记录和清除IE的历史记录
- 获取IE历史记录
- 如何访问IE历史记录
- Google Chrome 浏览器历史记录的获取与清除
- 如何清除Firefox 4中的历史记录、Cookies与缓存
- 如何清除本地shell历史记录
- 如何获取(清除)IE缓存地址信息
- 如何获取(清除)IE缓存地址信息
- 【原创】关于IE地址栏历史记录的清除
- VC 清除IE缓存、cookie、历史记录等
- VC 清除IE缓存、cookie、历史记录等
- 如何访问IE历史记录(续)
- 如何快速清除IE8浏览器的历史记录
- 如何清除Linux操作系统命令的历史记录
- 如何清除“远程桌面连接”的历史记录?
- SQL Server 开发之 复制表数据的SQL脚本生成器
- 移动互联网一周(2012.2.6-2012.2.12)大事记
- 如何获取(清除)IE缓存地址信息
- VB工程-- 百例79--字体屏保
- java二维数组
- 如何获取与清除IE历史记录
- 作业2
- 添加DOS命令(CMD控制台)到文件夹右键菜单
- 设置不同事件View背景颜色
- 文件传输协议(FTP)必将消亡
- JS , CSS ,image HTML DOM的加载过程 以及 总结JS的基本用法
- 嵌入式LINUX系统的程序安装操作步骤
- 修改sql server2008中的sa的登陆密码
- MS-VC 使用MAP文件快速定位程序崩溃代码行