Downloads bits from the Internet and saves them to a file.
Syntax:
HRESULT URLDownloadToFile(
LPUNKNOWN pCaller, LPCTSTR szURL, LPCTSTR szFileName, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB );Parameters:
pCallerPointer to the controlling IUnknown interface of the calling Microsoft ActiveX component (if the caller is an ActiveX component). szURLPointer to a string value containing the URL to be downloaded. Cannot be set to NULL.
szFileName
Pointer to a string value containing the name of the file to create for bits that come from the download.
dwReserved
#include "stdafx.h"
#include <iostream>
#include <UrlMon.h>
#pragma comment(lib, "urlmon.lib")
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//nt * dl = new int;
HRESULT hr = URLDownloadToFile(0, _T("http://ui.the9.com/wowshell/WoWShell.exe"),_T("D://WoWShell.exe"), 0,NULL);
if (hr== S_OK)
{
cout<< "ok"<< endl;
}
return 0;
}
本文介绍了一个用于从互联网下载资源并保存到本地文件的API:URLDownloadToFile。详细解释了该API的参数设置与使用方法,并提供了一个简单的示例程序来展示如何调用此API进行文件下载。
231

被折叠的 条评论
为什么被折叠?



