==================================================================
procedure DelRegCache;
//清除IE下拉列表中的网址
var
reg:TRegistry;
begin
reg:=Tregistry.create;
reg.RootKey:=HKEY_CURRENT_USER;
reg.DeleteKey('Software/Microsoft/Internet Explorer/TypedURLs');
reg.Free;
end;
==================================================================
function GetCookiesFolder:string;
//取得Cookie目录
var
pidl
ItemIDList;
buffer:array [ 0..255 ] of char ;
begin
//取得指定的目录,CSIDL_COOKIES表示Cookie目录
SHGetSpecialFolderLocation(
application.Handle , CSIDL_COOKIES, pidl);
//转化成文件系统的路径
SHGetPathFromIDList(pidl, buffer);
result:=strpas(buffer);
end;
function ShellDeleteFile(sFileName: string): Boolean;
//使用Shell删除文件
var
FOS: TSHFileOpStruct;
begin
FillChar(FOS, SizeOf(FOS), 0);
{记录清零}
with FOSdo
begin
wFunc := FO_DELETE;//删除
pFrom := PChar(sFileName);
fFlags := FOF_NOCONFIRMATION;
//删除时不提示
end;
Result := (SHFileOperation(FOS) = 0);
end;
procedure DelCookie;
//清空Cookie
var
dir:string;
begin
{关闭IE的Seeeion,停止Cookie会话}
InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, 0);
dir:=GetCookiesFolder;
ShellDeleteFile(dir+'/*.txt');
end;
===========================================================
procedure DelHistory;
// 清空历史记录
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord ;
dwEntrySize, dwLastError: LongWord;
begin
dwEntrySize := 0;
{取得缓冲区所需要的空间大小}
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
{分配空间}
GetMem(lpEntryInfo, dwEntrySize);
{检索第一个}
hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
FreeMem(lpEntryInfo);
{检索下一个}
repeat
dwEntrySize := 0;
{取得缓冲区所需要的空间大小}
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^),
dwEntrySize);
dwLastError := GetLastError();
if dwLastError = ERROR_INSUFFICIENT_BUFFER then
//如果成功
begin
GetMem(lpEntryInfo, dwEntrySize);
{分配dwEntrySize字节的内存}
if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
FreeMem(lpEntryInfo);
end;
until (dwLastError = ERROR_NO_MORE_ITEMS);
end;
================================================================================
以上代码摘自《Delphi下深入Windows核心编程》