lundi 1 décembre 2014

Problem with downloading images using URLDownloadToFile in vc++ [on hold]

The following function is taking a list of urls of images as parameter in the form of vector and the function I have used to download files is "URLDownloadToFile" but not a single time the images are downloaded--always same results "Unknown error".



void fun::update(vector<std::string>& list_url)
{

vector<std::string> res ;

HRESULT hr;
for(std::size_t i=0;i< list_url.size();i++)
{
res.push_back(list_url[i].substr( list_url[i].find_last_of("/") + 1 ));


LPCTSTR Url = (LPCTSTR)list_url[i].c_str();
LPCTSTR File =(LPCTSTR)res[i].c_str();


hr = URLDownloadToFile(0, Url,File , 0, 0);


switch (hr)
{
case S_OK:
cout << "Successful download\n";
break;
case E_OUTOFMEMORY:
cout << "Out of memory error\n";
break;
case INET_E_DOWNLOAD_FAILURE:
cout << "Cannot access server data\n";
break;
default:
cout << "Unknown error\n";
break;
}
}

}


The function "URLDownloadToFile(0, Url,File , 0, 0)" is responsible for downloading the files.


Aucun commentaire:

Enregistrer un commentaire