I'm trying to clear out the WinInet cache using Win32 API - by invalidating the cache entries, or deleting them (doesn't matter). I can't find any way to do this for the whole cache (other than iterating over each entry - example in C#, another in VB) - is this even possible?
4 Answers
Apparently, it is possible to (ab)use the Internet Options panel to clear the cache files by executing this:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
Will try to call this as a DLL.
Source: http://www.vbforums.com/archive/index.php/t-440508.html , comment by technorobbo

- 91,498
- 46
- 177
- 222
Do not use the method: RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 This is unsupported by Microsoft and has been shown to break the cache and cause all sorts of unusual problems.

- 1
- 1
-
Thanks. I didn't think this would still be relevant in 2019, but here we are :) – Piskvor left the building Jul 11 '19 at 16:11
I'm fairly certain doing the FindFirst/FindNextUrlCacheEntry() then DeleteUrlCacheEntry() is the only way to make sure it works across all versions of IE.
Alternatively you can use FindFirst/FindNextUrlCacheGroup() and DeleteUrlCacheGroup() with "CACHEGROUP_FLAG_FLUSHURL_ONDELETE" but you have to make sure you only delete what you want. For example, history, cookies and temporary internet files are all Cache groups.

- 53,608
- 15
- 131
- 222
-
In this case, I wouldn't mind deleting all those. Was hoping that there was an easier way; oh well. – Piskvor left the building May 05 '09 at 14:51
FTR: The exact meaning of the argument (8 above, means only Temporary Internet Files and not Cookies etc.) is explained e.g. on http://www.howtogeek.com/howto/windows/clear-ie7-browsing-history-from-the-command-line.
BTW: Unfortunately RunDll32 is asynchronous, which makes it not ideal for running before e.g. automated web tests. Would anybody have an idea either how to run this as a blocking call, or to how to programmatically find the exact directory name of the "Temporary Internet Files" directory so it can be polled until empty? Code it in C (need it in Java, could do JNI) is really the only option, huh? ;(
PS: How can one post a reply to an existing answer instead of starting a new answer on stackoverflow?

- 3,439
- 32
- 38
-
Thanks, the bit-mask is indeed relevant in the call. (and btw, when you reach reputation 50, you'll be able to leave comments on other people's questions and answers; until then, you can only comment on your own) – Piskvor left the building Sep 16 '10 at 09:25