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_s(tempout,
80,
"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_s(tempout,
80,
"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;
}