procedure DeleteIECache(httpStr: string); // 清理IE緩存,IE.cookies var
lpEntryInfo: PInternetCacheEntryInfo; hCacheDir: LongWord;
dwEntrySize: LongWord; cachefile: string; begin dwEntrySize
:= 0; FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^),
dwEntrySize); GetMem(lpEntryInfo, dwEntrySize); if dwEntrySize
> 0 then lpEntryInfo^.dwStructSize := dwEntrySize; hCacheDir :=
FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize); if hCacheDir
<> 0 then begin repeat if
(lpEntryInfo^.CacheEntryType) and (NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY
then cachefile := pchar(lpEntryInfo^.lpszSourceUrlName); if
pos(httpStr, cachefile) > 0 then //清除特定網(wǎng)站的cookies.例如baidu.com
DeleteUrlCacheEntry(pchar(cachefile)); //執(zhí)行刪除操作 FreeMem(lpEntryInfo,
dwEntrySize); dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize); if dwEntrySize > 0
then lpEntryInfo^.dwStructSize := dwEntrySize; until not
FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize); end;
FreeMem(lpEntryInfo, dwEntrySize); FindCloseUrlCache(hCacheDir);
end;
procedure TForm1.Button1Click(Sender: TObject); begin
DeleteIECache(Edit1.Text); end;
|