URLDownloadToFile函数

来源:互联网 发布:人工智能 英文 最新 编辑:程序博客网 时间:2024/06/06 04:20

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:

pCaller
Pointer to the controlling IUnknown interface of the calling Microsoft ActiveX component (if the caller is an ActiveX component).
szURL
Pointer 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
Reserved. Must be set to 0.
             lpfnCB
Pointer to the caller's IBindStatusCallback interface. URLDownloadToFile calls this interface's IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called.

 

 

 #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;
}

 

原创粉丝点击