Solved

How to use FindFirstUrlCacheEntry() function?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

895 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

12 Experts available now in Live!

Get 1:1 Help Now