Solved

How to use FindFirstUrlCacheEntry() function?

Posted on 1997-10-14
2
1,285 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Better understanding on C++ Class serialization and formats 9 80
Safe conversion? 4 72
gdb doesn't stop on breakpoint 2 98
Why  my code (program) build with old compiler? 11 79
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

821 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