RetrieveUrlCacheEntryStream function

Provides the most efficient and implementation-independent way to access the cache data.


HANDLE RetrieveUrlCacheEntryStream(
  _In_    LPCTSTR                     lpszUrlName,
  _Inout_ LPDWORD                     lpcbCacheEntryInfo,
  _In_    BOOL                        fRandomRead,
  _In_    DWORD                       dwReserved


lpszUrlName [in]

Pointer to a null-terminated string that contains the source name of the cache entry. This must be a unique name. The name string should not contain any escape characters.

lpCacheEntryInfo [out]

Pointer to an INTERNET_CACHE_ENTRY_INFO structure that receives information about the cache entry.

lpcbCacheEntryInfo [in, out]

Pointer to a variable that specifies the size, in bytes, of the lpCacheEntryInfo buffer. When the function returns, the variable receives the number of bytes copied to the buffer or the required size, in bytes, of the buffer. Note that this buffer size must accommodate both the INTERNET_CACHE_ENTRY_INFO structure and the associated strings that are stored immediately following it.

fRandomRead [in]

Whether the stream is open for random access. Set the flag to TRUE to open the stream for random access.

dwReserved [in]

This parameter is reserved and must be 0.

Return value

If the function succeeds, the function returns a valid handle for use in the ReadUrlCacheEntryStream and UnlockUrlCacheEntryStream functions.

If the function fails, it returns NULL. To get extended error information, call GetLastError.

Possible error values include the following.

Return codeDescription

The cache entry specified by the source name is not found in the cache storage.


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.



RetrieveUrlCacheEntryStream does not do any URL parsing, so a URL containing an anchor (#) will not be found in the cache, even if the resource is cached. For example, if the URL is passed, the function returns ERROR_FILE_NOT_FOUND even if is in the cache.

Cache clients that do not need URL data in the form of a file should use this function to access the data for a particular URL.

Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.

Note  WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]







Unicode and ANSI names

RetrieveUrlCacheEntryStreamW (Unicode) and RetrieveUrlCacheEntryStreamA (ANSI)

See also

WinINet Functions