我研究了 MSDN 上的文档,但它对我不起作用,我想知道我做错了什么?
我的代码如下,我试图过滤我的 IE 缓存,例如,只获取 cookie:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <wininet.h>
int main(void) {
DWORD dwEntrySize;
DWORD dw;
LPCTSTR filter = "cookie:";
INTERNET_CACHE_ENTRY_INFO * entry;
DWORD MAX_CACHE_ENTRY_INFO_SIZE = 4096;
HANDLE hCacheDir;
int nCount=0;
BOOL ok = FALSE;
dwEntrySize = MAX_CACHE_ENTRY_INFO_SIZE;
entry = malloc(dwEntrySize);
entry->dwStructSize = dwEntrySize;
printf("Reading IE cache\n");
hCacheDir = FindFirstUrlCacheEntry(filter, entry, &dwEntrySize);
if ( hCacheDir ) {
printf("%ws\n", entry->lpszLocalFileName);
nCount++;
do {
dwEntrySize = MAX_CACHE_ENTRY_INFO_SIZE;
entry = malloc(dwEntrySize);
entry->dwStructSize = dwEntrySize;
ok = FindNextUrlCacheEntry(hCacheDir, entry, &dwEntrySize);
if (ok && entry->lpszLocalFileName != NULL) {
printf("%ws\n", entry->lpszLocalFileName);
nCount++;
}
} while ( ok );
printf("**** end cache, total count: %d\n", nCount);
}
else {
dw = GetLastError();
printf("error code: %d\n", dw);
}
free(entry);
FindCloseUrlCache(hCacheDir);
return 0;
}