Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
URL Monikers
Reference
Functions
 URLDownloadToCacheFile Function

  Switch on low bandwidth view
URLDownloadToCacheFile Function

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_FAILThe operation failed.
E_OUTOFMEMORYThe buffer length is invalid, or there is insufficient memory to complete the operation.
S_OKThe 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.

 New for Windows Internet Explorer 8 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 Implementationurlmon.dll
Custom ImplementationNo
HeaderUrlmon.h
Import libraryUrlmon.lib
Minimum availabilityInternet Explorer 3.0
Minimum operating systems Windows NT 4.0, Windows 95
UnicodeImplemented as ANSI and Unicode versions.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("urlmon.dll", CharSet:=CharSet.Auto, SetLastError:=True)> Public Shared Function URLDownloadToCacheFile(ByVal lpUnkcaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwBufLength As Long, ByVal dwReserved As Long, ByVal IBindStatusCallback As Long) As Integer
End Function
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("urlmon.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int URLDownloadToCacheFile(long lpUnkcaller, string szURL, string szFileName, long dwBufLength, long dwReserved, long IBindStatusCallback);
Tags What's this?: c# (x) syntax (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker