如何过滤 FindFirstUrlCacheEntry()?

发布于 2024-07-30 09:26:02 字数 1534 浏览 5 评论 0原文

我已经研究了 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;
}

I have studied the documentation on MSDN, but it doesn't work for me, I am wondering what I'm doing wrong?

My code is as follows, I am trying to filter my IE cache, for example, to get only the cookies:

#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;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文