删除internet临时文件
【打印文章】
uses wininet
procedure TForm1.Button1Click(Sender: TObject);
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord (*Handle*);
dwEntrySize, dwLastError: LongWord;
begin
//Get size of first entry in dwEntrySize
dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
//Create structure that can hold entry
GetMem(lpEntryInfo, dwEntrySize);
//Get first cache entry and handle to retrieve next entry, output url
hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then
Memo1.Lines.Add(string(lpEntryInfo^.lpszSourceUrlName));
//Use this line to Delete
{DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);}
//free structure
FreeMem(lpEntryInfo);
//retrieve all subsequent entries
repeat
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
dwLastError := GetLastError();
if GetLastError = ERROR_INSUFFICIENT_BUFFER then begin
GetMem(lpEntryInfo, dwEntrySize);
if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then
Memo1.Lines.Add(string(lpEntryInfo^.lpszSourceUrlName));
FreeMem(lpEntryInfo);
end;
until dwLastError = ERROR_NO_MORE_ITEMS;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord (*Handle*);
dwEntrySize, dwLastError: LongWord;
begin
//Get size of first entry in dwEntrySize
dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
//Create structure that can hold entry
GetMem(lpEntryInfo, dwEntrySize);
//Get first cache entry and handle to retrieve next entry, output url
hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then
Memo1.Lines.Add(string(lpEntryInfo^.lpszSourceUrlName));
//Use this line to Delete
{DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);}
//free structure
FreeMem(lpEntryInfo);
//retrieve all subsequent entries
repeat
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
dwLastError := GetLastError();
if GetLastError = ERROR_INSUFFICIENT_BUFFER then begin
GetMem(lpEntryInfo, dwEntrySize);
if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then
Memo1.Lines.Add(string(lpEntryInfo^.lpszSourceUrlName));
FreeMem(lpEntryInfo);
end;
until dwLastError = ERROR_NO_MORE_ITEMS;
end;
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】