DelphiFAQ Home Search:
General :: Windows :: Internet Explorer
Resolve problems with Internet Explorer, fine tune your installation or just get rid of spyware/ adware and other malware.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Programmatically clear Internet Explorer's cache

Question:

I need a tool to empty IE's cache on a regular basis. How can I quickly write that myself?

Answer:

You can use a quick and dirty approach if you need to delete the cache only on one specific computer. In this case write a batch file that contains the following statements (replace 'administrator' with your user name):

del "c:\Temp\*.*" /ARSAH /s /q
del "c:\documents and settings\administrator\Recent\*.*" /s /q /a
del "c:\documents and settings\administrator\History\*.*" /s /q /a
del "c:\documents and settings\administrator\Temporary Internet Files\*.*" /s /q /a


If you want a more universal tool then look at the following Delphi code. You can also download the compiled executable here: Del_IE_Cache.exe (8 kB)

program Delete_IE_Cache;
 
 uses
   WinInet;
 
 {sc-----------------------------------------------------------------------
   Name:       DeleteIECache
   Parameters: -
 -----------------------------------------------------------------------sc}
 procedure DeleteIECache;
 var
   lpEntryInfo: PInternetCacheEntryInfo;
   hCacheDir: LongWord;
   dwEntrySize: LongWord;
 begin { DeleteIECache }
   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
       DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
       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; { hCacheDir<>0 }
   FreeMem(lpEntryInfo, dwEntrySize);
 
   FindCloseUrlCache(hCacheDir)
 end; { DeleteIECache }
 
 
 begin
   DeleteIECache
 end.

Generated 16:02:25 on Feb 21, 2017