Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to delete the cache in the folder when ie running in protected mode?Thanks...
Posted
Comments
Satheesh1546 23-Dec-11 7:03am    
Not clear...
kiang3@foxmail.com 23-Dec-11 8:25am    
Dear Satheesh,Thank you very much for your reply ,it means,how to delete the IE cache when it running in protected mode,I know the folder is "low",but i don't know how to delete them...do you have any good idea share with me ?thanks a lot...
kiang3@foxmail.com 23-Dec-11 23:05pm    
Dear Satheesh,Is very pleased with your answer,But,I found,when the IE running in protected mode,it has another folder "low" under the path :%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low ,Seemingly,it can not be deleted using FindFirstUrlCacheEntry API,Have you encountered?Thanks in advance...

1 solution

Hi,

WinInet library provides lot of function for deleting cache .Please try the following
C++
#include <wininet.h>
#include <shlguid.h>
#include <urlhist.h>

void __fastcall ClearCache()
{
   DWORD dwSize = sizeof(INTERNET_CACHE_ENTRY_INFO); 
   INTERNET_CACHE_ENTRY_INFO *info = (INTERNET_CACHE_ENTRY_INFO*) LocalAlloc(LMEM_FIXED, dwSize); 
   if( info )
   {
      HANDLE hFind = FindFirstUrlCacheEntry(NULL, info, &dwSize); 
      if( hFind == NULL )
      {
         if( GetLastError() == ERROR_INSUFFICIENT_BUFFER )
         { 
            info = (INTERNET_CACHE_ENTRY_INFO*) LocalReAlloc(info, dwSize, LMEM_FIXED); 
            if( info )
               hFind = FindFirstUrlCacheEntry(NULL, info, &dwSize); 
         }
      }

      if( hFind != NULL ) 
      { 
         do
         {
            if( info->CacheEntryType & NORMAL_CACHE_ENTRY )
            {
               DeleteFile(info->lpszLocalFileName);
               DeleteUrlCacheEntry(info->lpszSourceUrlName);
            }

            if( FindNextUrlCacheEntry(hFind, info, &dwSize) )
               continue;

            if( GetLastError() == ERROR_INSUFFICIENT_BUFFER )
            { 
               info = (INTERNET_CACHE_ENTRY_INFO*) LocalReAlloc(info, dwSize, LMEM_FIXED); 
               if( info )
               {
                  if( FindNextUrlCacheEntry(hFind, info, &dwSize) )
                        continue;
               }
            }

            break;

         }
         while( true );

         FindCloseUrlCache(hFind);
      } 

      if( info )
         LocalFree(info); 
   }
}

void __fastcall ClearHistory()
{
   TComInterface<IUrlHistoryStg2> History;
   if( SUCCEEDED(CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2, (void **)&History)) )
      History->ClearHistory();
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900