Place a button and a TMemo component onto a form.
This code will show the files into the Memo component.
You can delete them by unmarking the Delete code.
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;