|
Location: Desktop development - C/C++ License: The Intelliproject Open License (IPOL) Download a remote file from a valid URL in C++Posted by Silviu CarageaYou can use this code to download a remote file from a valid URL using API functions or MFC classes |
Skill: IntermediatePosted: 02/11/2008Views: 905Rating: 0.00 /5Popularity: 0.00 |
| Sign Up to vote for this article |
Sometimes you need to download the content of a remote file into a buffer for subsequent processing.
You can do this in many ways:
InternetReadFile which reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest function.CInternetSession.The goal of this article is to describe the last 2 methods mentioned above.
API functions used above:
InternetOpen - Initializes an application's use of the WinINet functions.InternetOpenUrl - Opens a resource specified by a complete FTP, Gopher, or HTTP URL.HttpQueryInfo - Retrieves header information associated with an HTTP request.InternetReadFile - Reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest function.InternetCloseHandle - Closes a single Internet handle.As follows I will describe a wrapper class which will incapsulate the CInternetSession functionality .To use this class you should include afxinet.h (#include <afxinet.h>)
1. Using method based on API functions
2. Using method based on MFC classes
This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)
| Silviu Caragea
| Silviu Caragea is the Founder, Administrator and Chief Editor who wrote and runs The IntelliProject. He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy. His programming experience includes: - C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL) - Open Source libraries :CURL & Boost - HTML, CSS - Java (SE,ME) - JavaScript, Ajax, Google Web Toolkit (GWT) - Php, MySQL -Oracle, PL SQL - C# .NET -Objective C, IPhone SDK, Cocoa Location: |
Sign up to post message on the article message board!