procedure TForm1.Button4Click(Sender: TObject);
var
FirstCacheHandle: THandle;
PFirstCacheEntryInfo,PNextCacheEntryInfo: PInternetCacheEntryInfoA;
FirstCacheEntryInfo,NextCacheEntryInfo: TInternetCacheEntryInfoA;
FirstCacheEntryInfoBufferSize,NextCacheEntryInfoBufferSize: Dword;
HaveItem :Boolean;
begin
HaveItem := True;
FirstCacheEntryInfoBufferSize := 0;
NextCacheEntryInfoBufferSize := 0;
FirstCacheEntryInfo.dwStructSize := FirstCacheEntryInfoBufferSize;
NextCacheEntryInfo.dwStructSize := NextCacheEntryInfoBufferSize;
GetMem(PFirstCacheEntryInfo,sizeof(TInternetCacheEntryInfoA));
GetMem(PNextCacheEntryInfo,sizeof(TInternetCacheEntryInfoA));
//Dispose(PNextCacheEntryInfo);
PFirstCacheEntryInfo^.dwStructSize := sizeof(TInternetCacheEntryInfoA);
PNextCacheEntryInfo^.dwStructSize := sizeof(TInternetCacheEntryInfoA);
FirstCacheHandle := 0;
while FirstCacheHandle=0 do
begin
FirstCacheHandle :=FindFirstUrlCacheEntryEx
('',0,URLCACHE_FIND_DEFAULT_FILTER
,0,PFirstCacheEntryInfo,@FirstCacheEntryInfoBufferSize,nil,nil,nil);
if FirstCacheHandle =0 then
begin
//Freemem(PFirstCacheEntryInfo);
case GetLastError of
ERROR_NO_MORE_ITEMS :
begin
FindCloseUrlCache(FirstCacheHandle);
FreeMem(PFirstCacheEntryInfo);
Break;
end;
ERROR_INSUFFICIENT_BUFFER :
begin
FreeMem(PFirstCacheEntryInfo);
GetMem(PFirstCacheEntryInfo,FirstCacheEntryInfoBufferSize);
PFirstCacheEntryInfo^.dwStructSize := FirstCacheEntryInfoBufferSize;
continue;
end;
else
begin
showmessage('Can not Press Cache!');
Break;
end;
end;
end;
end ;
try
while HaveItem=true do
begin
if not (FindNextUrlCacheEntryEx(FirstCacheHandle,PNextCacheEntryInfo,
@NextCacheEntryInfoBufferSize,nil,nil,nil)) then
begin
//FreeMem(PNextCacheEntryInfo);
case GetLastError of
ERROR_NO_MORE_ITEMS :
begin
FindCloseUrlCache(FirstCacheHandle);
HaveItem :=false;
continue;
end;
ERROR_INSUFFICIENT_BUFFER :
begin
FreeMem(PNextCacheEntryInfo);
GetMem(PNextCacheEntryInfo,NextCacheEntryInfoBufferSize);
PNextCacheEntryInfo^.dwStructSize := NextCacheEntryInfoBufferSize;
continue;
end;
else
begin
FreeMem(PNextCacheEntryInfo);
showmessage('Error');
Break;
end;
end;
end
else
begin
Listbox1.items.add(strpas(PNextCacheEntryInfo^.lpszSourceUrlName));
Listbox2.items.add(strpas(PNextCacheEntryInfo^.lpszLocalFileName));
end;
end;
except
end;
//freemem(PFirstCacheEntryInfo);
//freemem(PNextCacheEntryInfo);
//Dispose(PFirstCacheEntryInfo);
end;