Export (0) Print
Expand All
1 out of 5 rated this helpful - Rate this topic

URLDownloadToCacheFile function

Downloads data to the Internet cache and returns the file name of the cache location for retrieving the bits.

Syntax


HRESULT URLDownloadToCacheFile(
  _In_        LPUNKNOWN lpUnkcaller,
  _In_        LPCSTR szURL,
  _Out_       LPTSTR szFileName,
  _In_        DWORD cchFileName,
  _Reserved_  DWORD dwReserved,
  _In_opt_    IBindStatusCallback *pBSC
);

Parameters

lpUnkcaller [in]

A pointer to the controlling IUnknown interface of the calling 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 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, optional]

A pointer to the IBindStatusCallback interface of the caller. By using IBindStatusCallback::OnProgress, a caller can receive download status. URLDownloadToCacheFile calls the IBindStatusCallback::OnProgress and IBindStatusCallback::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.

Return codeDescription
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.

Windows 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.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Product

Internet Explorer 3.0

Header

Urlmon.h

Library

Urlmon.lib

DLL

Urlmon.dll

Unicode and ANSI names

URLDownloadToCacheFileW (Unicode) and URLDownloadToCacheFileA (ANSI)

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.