Link to home
Start Free TrialLog in
Avatar of winniet
winniet

asked on

How to use FindFirstUrlCacheEntry() function?

Hi, I want to use FindFirstUrlCacheEntry() to search cache for some specific URL files, I don't know how to initialize the parameters of this function. From the document, I don't know how to set them. Please give me a example.
HANDLE FindFirstUrlCacheEntry (    
[IN] LPCSTR lpszUrlSearchPattern,
[OUT] LPINTERNET_CACHE_ENTRY_INFO lpFirstCacheEntryInfo,
[IN OUT] LPDWORD lpdwFirstCacheEntryInfoBufferSize);
ASKER CERTIFIED SOLUTION
Avatar of eugenem
eugenem

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eugenem
eugenem

There is the sample.

#include <windows.h>
#include <iostream.h>
#include <wininet.h>


void main()
{
      LPCSTR lpszUrlSearchPattern = "*.*";
      LPINTERNET_CACHE_ENTRY_INFO lpCEInfo = new INTERNET_CACHE_ENTRY_INFO;
      DWORD dwBufferSize = MAX_CACHE_ENTRY_INFO_SIZE;

      lpCEInfo->dwStructSize = MAX_CACHE_ENTRY_INFO_SIZE;

      HANDLE hEnumHandle = FindFirstUrlCacheEntry(
         lpszUrlSearchPattern,
         lpCEInfo,
         &dwBufferSize
      );
      if( hEnumHandle == NULL )
            cout << GetLastError();
      else
      {
            do
            {
                  lpCEInfo->dwStructSize = MAX_CACHE_ENTRY_INFO_SIZE;
                  dwBufferSize = MAX_CACHE_ENTRY_INFO_SIZE;
            }
            while( FindNextUrlCacheEntry( hEnumHandle, lpCEInfo, &dwBufferSize ) );
      }
      FindCloseUrlCache( hEnumHandle );
}