Deleting the Internet Explorer Cache programmatically

2004-01-12 12:05:00 +0000

char buffer[4096];
DWORD cb = 4096;

INTERNET_CACHE_ENTRY_INFO *p = (INTERNET_CACHE_ENTRY_INFO *)buffer;
HANDLE h = FindFirstUrlCacheEntry(NULL, p, &cb);
while (h)
{
    // Do something with it...
    printf("Deleting: %s...", p->lpszSourceUrlName);
    if (!DeleteUrlCacheEntry(p->lpszSourceUrlName))
    {
        printf("failed, 0x%x\n", GetLastError());
    }
    else
        printf("ok\n");

    cb = 4096;
    if (!FindNextUrlCacheEntry(h, (INTERNET_CACHE_ENTRY_INFO *)buffer, &cb))
        break;
}