Header: Declared in Wininet.h.
Library: Use Wininet.lib.
BOOL bResult = FALSE;
BOOL bDone = FALSE;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL;
DWORD dwTrySize, dwEntrySize = 4096; // start buffer size
HANDLE hCacheDir = NULL;
DWORD dwError = ERROR_INSUFFICIENT_BUFFER;
do
{
switch (dwError)
{
// need a bigger buffer
case ERROR_INSUFFICIENT_BUFFER:
delete [] lpCacheEntry;
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
lpCacheEntry->dwStructSize = dwEntrySize;
dwTrySize = dwEntrySize;
BOOL bSuccess;
if (hCacheDir == NULL)
bSuccess = (hCacheDir
= FindFirstUrlCacheEntry(NULL, lpCacheEntry,
&dwTrySize)) != NULL;
else
bSuccess = FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize);
if (bSuccess)
dwError = ERROR_SUCCESS;
else
{
dwError = GetLastError();
dwEntrySize = dwTrySize; // use new size returned
}
break;
// we are done
case ERROR_NO_MORE_ITEMS:
bDone = TRUE;
bResult = TRUE;
break;
// we have got an entry
case ERROR_SUCCESS:
// don't delete cookie entry
// if (!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
{
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
AddEventToList(WBListBox, lpCacheEntry->lpszSourceUrlName);
}
// get ready for next entry
dwTrySize = dwEntrySize;
if (FindNextUrlCacheEntry(hCacheDir, lpCacheEntry, &dwTrySize))
dwError = ERROR_SUCCESS;
else
{
dwError = GetLastError();
dwEntrySize = dwTrySize; // use new size returned
}
break;
// unknown error
default:
bDone = TRUE;
break;
}
if (bDone)
{
delete [] lpCacheEntry;
if (hCacheDir)
FindCloseUrlCache(hCacheDir);
}
} while (!bDone);
반응형
'IT-개발,DB' 카테고리의 다른 글
[개발/VC++] Visual C++ 에서 컴파일시 LNK2019 에러에 대한 해결방법 (0) | 2011.12.06 |
---|---|
[개발/VC] 다이얼로그 바탕화면에서 자석효과 구현 (0) | 2011.12.02 |
[개발/VC++] fatal error C1083: 포함 파일을 열 수 없습니다. 'stdafx.h': No such file or directory (0) | 2011.11.17 |
[개발/MFC] 비스타 이상에서 권한이 낮은 프로세스에서 WM_COPYDATA 메세지 전송 (0) | 2011.11.16 |
[개발/mfc] WINDOWS API를 이용한 암호화 간단 예제 (0) | 2011.11.08 |
댓글