Downloads data to the Internet cache and returns the file name of the cache location for retrieving the bits.
Syntax
HRESULT URLDownloadToCacheFile(
LPUNKNOWN lpUnkcaller,
LPCSTR szURL,
LPTSTR szFileName,
DWORD cchFileName,
DWORD dwReserved,
IBindStatusCallback *pBSC
);
Parameters
- lpUnkcaller
-
[in] A pointer to the controlling IUnknown interface of the calling Microsoft ActiveX component, if the caller is an ActiveX component. If the caller is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component, such as an ActiveX control in the context of an HTML page. This parameter represents the outermost IUnknown of the calling component. The function attempts the download in the context of the ActiveX client framework, and allows the caller container to receive callbacks on the progress of the download.
- szURL
-
[in] A pointer to a string value that contains the URL to download. Cannot be set to NULL.
- szFileName
-
[out] A pointer to a string value that contains the name of the downloaded file. Cannot be set to NULL.
- cchFileName
-
[in] An unsigned long integer value that contains the number of characters of the szFileName value.
- dwReserved
-
Reserved. Must be set to 0.
- pBSC
-
[in] A pointer to the IBindStatusCallback interface of the caller. By using OnProgress, a caller can receive download status. URLDownloadToCacheFile calls the OnProgress and OnDataAvailable methods as data is received. The download operation can be canceled by returning E_ABORT from any callback. This parameter can be set to NULL if status is not required.
Return Value
Returns one of the following values.
| E_FAIL | The operation failed. |
| E_OUTOFMEMORY | The buffer length is invalid, or there is insufficient memory to complete the operation. |
| S_OK | The operation succeeded. |
Remarks
The client can choose to be notified of progress through a notification callback.
This function always returns a file name, if the download operation succeeds. If the given URL is a "file:" URL, URLDownloadToCacheFile directly returns the file name for the "file:" URL, instead of making a copy to the cache. If the given URL is an Internet URL, such as "http:" or "ftp:," URLDownloadToCacheFile downloads this file and returns the local file name of the cached copy. Use this function to ensure that a file name is returned without unnecessary copying of data.
Internet Explorer 8. URLDownloadToCacheFile does not support IBindStatusCallbackEx and cannot be used to download files over 4 gigabytes (GB) in size. Refer instead to IBindStatusCallbackEx::GetBindInfoEx for a code example.
Function Information
| Stock Implementation | urlmon.dll |
|---|
| Custom Implementation | No |
|---|
| Header | Urlmon.h |
|---|
| Import library | Urlmon.lib |
|---|
| Minimum availability | Internet Explorer
3.0 |
|---|
| Minimum operating systems |
Windows NT 4.0, Windows 95 |
|---|
| Unicode | Implemented as
ANSI and Unicode versions. |
|---|