Solved

Downloading Internet Files

Posted on 1998-01-23
1
615 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 100 total points
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Shell script to login to remote m/c and execute commands 10 72
fizzArray2 challenge 1 55
EvenOdd challenge 10 81
FizzBuzz challenge 9 71
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now