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

博客介绍了使用WinAPI枚举IE缓存条目的方法。需将Wininet.lib加到工程里,通过FindFirstUrlCacheEntry和FindNextUrlCacheEntry函数来遍历缓存条目,处理可能出现的错误,如缓冲区不足等情况,并统计缓存条目数量。

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

<?php if ( ! defined( 'ABSPATH' ) ) exit; ?> <!DOCTYPE html> <html <?php language_attributes(); ?> <?php SWELL_Theme::root_attrs(); ?>> <head> <meta charset="utf-8"> <meta name="format-detection" content="telephone=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, viewport-fit=cover"> <?php wp_head(); $SETTING = SWELL_Theme::get_setting(); // SETTING取得 ?> <meta itemprop="name" content="你的页面标题"> <meta itemprop="description" content="页面描述,建议不超过40字"> <meta itemprop="image" content="https://example.com/thumb.jpg"> </head> <body> <?php if ( function_exists( 'wp_body_open' ) ) wp_body_open(); ?> <div id="body_wrap" <?php body_class(); ?> <?php SWELL_Theme::body_attrs(); ?>> <?php // SPメニュー $cache_key = $SETTING['cache_spmenu'] ? 'spmenu' : ''; SWELL_Theme::get_parts( 'parts/header/sp_menu', null, $cache_key ); // ヘッダー $cache_key = ''; if ( $SETTING['cache_header'] ) { $cache_key = ( SWELL_Theme::is_top() && ! is_paged() ) ? 'header_top' : 'header_notop'; } SWELL_Theme::get_parts( 'parts/header/header_contents', null, $cache_key ); // Barba用 wrapper if ( SWELL_Theme::is_use( 'pjax' ) ) { echo '<div data-barba="container" data-barba-namespace="home">'; } // メインビジュアル if ( SWELL_Theme::is_use( 'mv' ) ) { $cache_key = $SETTING['cache_top'] ? 'mv' : ''; SWELL_Theme::get_parts( 'parts/top/main_visual', null, $cache_key ); } // MV下通知バー // if ( 1 ) { // $cache_key = $SETTING['cache_top'] ? 'mv_info' : ''; // SWELL_Theme::get_parts( 'parts/top/mv_info', null, $cache_key ); // } // 記事スライダー if ( SWELL_Theme::is_use( 'post_slider' ) ) { $cache_key = $SETTING['cache_top'] ? 'post_slider' : ''; SWELL_Theme::get_parts( 'parts/top/post_slider', null, $cache_key ); } // タイトル(コンテンツ上) if ( SWELL_Theme::is_show_ttltop() ) SWELL_Theme::get_parts( 'parts/top_title_area' ); // ぱんくず if ( 'top' === $SETTING['pos_breadcrumb'] ) SWELL_Theme::get_parts( 'parts/breadcrumb' ); ?> <div id="content" class="l-content l-container" <?php SWELL_Theme::content_attrs(); ?>> <?php // ピックアップバナー if ( SWELL_Theme::is_show_pickup_banner() ) { $cache_key = $SETTING['cache_top'] ? 'pickup_banner' : ''; SWELL_Theme::get_parts( 'parts/top/pickup_banner', null, $cache_key ); }
最新发布
10-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值