您的位置:首页 > 其它

判断IE的缓冲文件存储的位置并取得该文件

2005-03-17 02:29 399 查看
将Wininet.lib加到工程里去
int WINAPI EnumerateCacheOld(HWND hX)
{
DWORD dwEntrySize;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry;
DWORD MAX_CACHE_ENTRY_INFO_SIZE=4096;
HANDLE hCacheDir;
int nCount=0;
SendDlgItemMessage(hX,IDC_CacheList,LB_RESETCONTENT,0,0);

SetCursor(LoadCursor(NULL,IDC_WAIT));
dwEntrySize = MAX_CACHE_ENTRY_INFO_SIZE;
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
lpCacheEntry->dwStructSize = dwEntrySize;
again:
if (!(hCacheDir = FindFirstUrlCacheEntry(NULL,lpCacheEntry,&dwEntrySize)))
{
delete[]lpCacheEntry;
switch(GetLastError())
{
case ERROR_NO_MORE_ITEMS:
char tempout[80];
sprintf(tempout,"The number of cache entries = %d /n",nCount);
MessageBox(hX,tempout,"Cache Enumeration",MB_OK);
FindCloseUrlCache(hCacheDir);
SetCursor(LoadCursor(NULL,IDC_ARROW));
return TRUE;
break;
case ERROR_INSUFFICIENT_BUFFER:
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO)
new char[dwEntrySize];
lpCacheEntry->dwStructSize = dwEntrySize;
goto again;
break;
default:
ErrorOut(hX,GetLastError(),"FindNextUrlCacheEntry Init");
FindCloseUrlCache(hCacheDir);
SetCursor(LoadCursor(NULL,IDC_ARROW));
return FALSE;
}
}
SendDlgItemMessage(hX,IDC_CacheList,LB_ADDSTRING,
0,(LPARAM)(lpCacheEntry->lpszSourceUrlName));
nCount++;
delete (lpCacheEntry);
do
{
dwEntrySize = MAX_CACHE_ENTRY_INFO_SIZE;
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
lpCacheEntry->dwStructSize = dwEntrySize;
retry:
if (!FindNextUrlCacheEntry(hCacheDir,lpCacheEntry, &dwEntrySize))
{
delete[]lpCacheEntry;
switch(GetLastError())
{
case ERROR_NO_MORE_ITEMS:
char tempout[80];
sprintf(tempout,"The number of cache entries =
%d /n",nCount);
MessageBox(hX,tempout,"Cache Enumeration",MB_OK);
FindCloseUrlCache(hCacheDir);
return TRUE;
break;
case ERROR_INSUFFICIENT_BUFFER:
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO)
new char[dwEntrySize];
lpCacheEntry->dwStructSize = dwEntrySize;
goto retry;
break;
default:
ErrorOut(hX,GetLastError(),"FindNextUrlCacheEntry Init");
FindCloseUrlCache(hCacheDir);
return FALSE;
}
}
SendDlgItemMessage(hX,IDC_CacheList,LB_ADDSTRING,
0,(LPARAM)(lpCacheEntry->lpszSourceUrlName));
nCount++;
delete[] lpCacheEntry;
}
while (TRUE);
SetCursor(LoadCursor(NULL,IDC_ARROW));
return TRUE;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: