Solved

Downloading Internet Files

Posted on 1998-01-23
1
623 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 59
fizzArray  challenge 1 115
wait notify demo infinite loop 3 151
listing all the respondents to a twitter feed - Java 5 49
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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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