Solved

How to use FindFirstUrlCacheEntry() function?

Posted on 1997-10-14
2
1,220 Views
Last Modified: 2011-09-20
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);
0
Comment
Question by:winniet
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
eugenem earned 100 total points
ID: 1171436
FindFirstUrlCacheEntry


HANDLE FindFirstUrlCacheEntry (
    IN LPCSTR lpszUrlSearchPattern,
    OUT LPINTERNET_CACHE_ENTRY_INFO lpFirstCacheEntryInfo,
    IN OUT LPDWORD lpdwFirstCacheEntryInfoBufferSize
);

Begins the enumeration of the cache.

Returns a handle that the application can use in the FindNextUrlCacheEntry function to retrieve subsequent entries in the cache. If the function fails, the return value is NULL. To get extended error information, call GetLastError. ERROR_INSUFFICIENT_BUFFER indicates that the size of lpCacheEntryInfo as specified by lpdwCacheEntryInfoBufferSize is not sufficient to contain all the information. The value returned in lpdwCacheEntryInfoBufferSize indicates the buffer size necessary to contain all the information.
lpszUrlSearchPattern
Address of a string that contains the source name pattern to search for. If this parameter is NULL, the function uses *.*. (In this version, only *.* semantics are implemented.)
lpFirstCacheEntryInfo
Address of an INTERNET_CACHE_ENTRY_INFO structure.
lpdwFirstCacheEntryInfoBufferSize
Address of a variable that specifies the size of the lpFirstCacheEntryInfo buffer. When the function returns, the variable contains the number of bytes copied to the buffer, or the required size of the buffer.
This function and the FindNextUrlCacheEntry function return variable size information. In order to not have the enumeration terminate due to ERROR_INSUFFICIENT_BUFFER, an application should create one buffer of the size specified by the MAX_CACHE_ENTRY_INFO_SIZE value, and pass the address of the buffer repeatedly to all the enumeration functions. After the function succeeds, another buffer may be used of the size returned by lpdwCacheEntryInfoBufferSize to keep the returned information. Be careful to fix the pointer elements while copying the buffer.

FindNextUrlCacheEntry


BOOL FindNextUrlCacheEntry(
    IN HANDLE hEnumHandle,
    OUT LPINTERNET_CACHE_ENTRY_INFO lpNextCacheEntryInfo,
    IN OUT LPWORD lpdwNextCacheEntryInfoBufferSize
);

Retrieves the next entry in the cache.

Returns TRUE if successful, or FALSE otherwise. To get extended error information, call GetLastError. Possible error values include: Value  Meaning  
ERROR_NO_MORE_FILES  The enumeration completed.  
ERROR_INSUFFICIENT_BUFFER  The size of lpCacheEntryInfo as specified by lpdwCacheEntryInfoBufferSize is not sufficient to contain all the information. The value returned in lpdwCacheEntryInfoBufferSize indicates the buffer size necessary to contain all the information.  

hEnumHandle
Enumeration handle obtained from a previous call to FindFirstUrlCacheEntry.
lpNextCacheEntryInfo
Address of an INTERNET_CACHE_ENTRY_INFO structure that receives information about cache entry.
lpdwNextCacheEntryInfoBufferSize
Address of a variable that specifies the size of the lpNextCacheEntryInfo buffer. When the function returns, the variable contains the number of bytes copied to the buffer, or the required size of the buffer.

INTERNET_CACHE_ENTRY_INFO



typedef struct _CACHE_ENTRY_INFO {
    DWORD dwStructSize;
    LPSTR lpszSourceUrlName;
    LPTSTR lpszLocalFileName;
    DWORD CacheEntryType;
    DWORD dwUseCount;
    DWORD dwHitRate;
    DWORD dwSizeLow;
    DWORD dwSizeHigh;
    FILETIME LastModifiedTime;
    FILETIME ExpireTime;
    FILETIME LastAccessTime;
    FILETIME LastSyncTime;
    LPBYTE lpHeaderInfo;
    DWORD dwHeaderInfoSize;
    LPTSTR lpszFileExtension;
    DWORD dwReserved;
} INTERNET_CACHE_ENTRY_INFO, *LPINTERNET_CACHE_ENTRY_INFO;

Contains information about an entry in the cache.

dwStructSize
Size, in bytes, of this structure.
lpszSourceUrlName
Address of a string that contains the URL name. The string occupies memory area at the end of this structure.
lpszLocalFileName
Address of a string that contains the local file name. The string occupies memory area at the end of this structure.
CacheEntryType
Cache type bit mask. Can be one of these values: Value  Meaning  
NORMAL_CACHE_ENTRY  Normal cache entry; may be deleted to recover space for new entries.  
STABLE_CACHE_ENTRY  Stable cache entry such as graphic and audio/video files; may be deleted to recover space for the new entries only when there is no more NORMAL_CACHE_ENTRY.  
STICKY_CACHE_ENTRY  Entries that will never be removed automatically by the cache management system.  
SPARSE_CACHE_ENTRY  This cache entry is incomplete.  
OCX_CACHE_ENTRY  Special OCX type cache entry.  

dwUseCount
Current user count of the cache entry.
dwHitRate
Number of times the cache entry was retrieved.
dwSizeLow
Low-order double word of the file size.
dwSizeHigh
High-order double word of the file size.
LastModifiedTime
Last modified time of this URL in GMT format.
ExpireTime
Expiration time of this file in GMT format.
LastAccessTime
Last accessed time in GMT format.
LastSyncTime
Last time the cache was synchronized.
lpHeaderInfo
Address of a buffer that contains the header information. The buffer occupies memory at the end of this structure.
dwHeaderInfoSize
Size of the lpHeaderInfo buffer.
lpszFileExtension
Address of a string that contains the file extension used to retrieve the data as a file. The string occupies memory area at the end of this structure.
dwReserved
Reserved; must be zero.
The MAX_CACHE_ENTRY_INFO_SIZE value defines the maximum size of the INTERNET_CACHE_ENTRY_INFO structure that could be returned by the implementation of the cache functions. Thus passing in a buffer of this size in functions returning INTERNET_CACHE_ENTRY_INFO guarantees that the function does not fail because of an insufficient buffer.

0
 
LVL 3

Expert Comment

by:eugenem
ID: 1171437
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 );
}

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now