本文介绍了当以保护模式运行时,如何删除文件夹中的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以保护模式运行时如何删除文件夹中的缓存?谢谢...
How to delete the cache in the folder when ie running in protected mode?Thanks...
推荐答案
#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();
}
这篇关于当以保护模式运行时,如何删除文件夹中的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!