Solved

How to use FindFirstUrlCacheEntry() function?

Posted on 1997-10-14
2
1,305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Building cUrl in Windows v7.43.0 4 42
Template syntax for variable length arrays 9 78
Precision Problem in C++ 7 65
Indy 10 not Receiving UDP broadcast 3 53
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

738 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