AI摘要

本文介绍了一个使用WinInet库的Delphi程序,用于删除IE临时文件。程序首先创建一个TStringList对象,然后通过FindFirstUrlCacheEntry和FindNextUrlCacheEntry函数遍历缓存文件,检查文件名是否包含特定字符串(如"Delphibbs.com"),如果符合条件,则将其添加到列表中。最后,通过DeleteUrlCacheEntry函数删除这些文件,并释放内存和关闭缓存目录。
本文介绍了一个使用

uses
 WinInet;

procedure DeleteIECache; //清理IE缓存
var
 lpEntryInfo: PInternetCacheEntryInfo;
 hCacheDir: LongWord;
 dwEntrySize: LongWord;
 cachefile: string;
 i: integer;
 cancheqqlist: TStringList;
begin
 cancheqqlist := TStringList.Create;
 cancheqqlist.Clear;
 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('Delphibbs.com', cachefile) > 0 then //符合条件的清除
       cancheqqlist.Add(cachefile);
     for i := 0 to cancheqqlist.Count - 1 do
       DeleteUrlCacheEntry(pchar(cancheqqlist.Strings[i])); //执行删除
     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);
 cancheqqlist.Free;
end;

※相关文章推荐※



最后修改:2009 年 08 月 16 日
点赞的人是最酷的