Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Downloading Internet Files

Posted on 1998-01-23
1
Medium Priority
?
628 Views
Last Modified: 2013-11-20
I am working on an application to download a file from the Internet. I can do this successfully via the http functions but I'd like to put the retrieved file into cache. Does anyone know how to use the URLDownloadToCacheFile() function? Is this the right one? Do I have to be connected to the Internet first before I use it? What gives this command an Internet context? Any sample code anywhere?
0
Comment
Question by:rhans042197
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1314638
Yes, the URLDownloadToCacheFile() function is the right one. The latest Internet Client SDK has more information about the 4th parameter.

dwBufLength
DWORD value that contains the size of the szFileName buffer or a flag. If a flag is set to dwBufLength, the buffer is assumed to be of size MAX_PATH. The flag can be one of the following values:
URLOSTRM_USECACHEDCOPY_ONLY  Only download the resource from the cache.  
URLOSTRM_USECACHEDCOPY  Download the resource from the cache if it is available; otherwise, download it from the Internet.  
URLOSTRM_GETNEWESTVERSION  Download the resource from the Internet, if it is newer, and store it in the cache.  

A simple example:

TCHAR pszFilename[MAX_PATH];

HRESULT hr = ::URLDownloadToCacheFile(NULL,  // for non ActiveX component
                                      _T("http://www.somewhere.com/somefile.dat"),
                                      pszFilename,
                                      URLOSTRM_USECACHEDCOPY,
                                      0,
                                      NULL);

if (SUCCEEDED(hr))
{
    // the file has been successfully downloaded, pszFilename contains the cached file name
}

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

916 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