We help IT Professionals succeed at work.

Deleting IE cache

jexd99
jexd99 asked
on

Is there an api for deleting all IE cache files?
I don't care to read through the folders or do anything fancy, I just want to wipe it out programmatically via an api call, and I don't want to use a component for this.  I would expect there to be an api, as Windows has an option on there start-menu for clearing this, but I can't find any. Does anyone know if there is an api for this?

          Thanks
Comment
Watch Question

Mohammed NasmanSoftware Developer
BRONZE EXPERT

Commented:
Hello
 
  you can do that using DeleteUrlCacheEntry api from wininet unit

look at this link for a sample
http://www.delphipages.com/tips/thread.cfm?ID=84

and for more info look at msdn site
http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/wininet/reference/functions/DeleteUrlCacheEntry.asp

Best regards
Mohammed Nasman

Commented:
listening
Commented:
or you can use this puppy:

add:

uses wininet

procedure delcache;
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
  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
            FreeMem(lpEntryInfo);
   end;
 until dwLastError = ERROR_NO_MORE_ITEMS;
end;  

Author

Commented:

Thank you for the answers. I was hoping there was an api just to wipe "all" clean as I don't care to parse it and don't want to read through all the files. But this gets the job done the same.

          Thanks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.