I am using UrlToDownloadFile function, but it doesn't download the file. No error shown in compiler (using VStudio 2012)
Here is the code:
#include <Windows.h>
#include "urlmon.h"
#pragma lib "urlmon.lib"
using namespace std;
void dwFile();
int _tmain(int argc, _TCHAR* argv[])
{
dwFile ();
return 0;
}
void dwFile ()
{
LPCSTR url = ("http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf");
LPCSTR fPath = ("C:\\Users\\Andyy\\Desktop\\test\\n3337.pdf");
HRESULT URLDownloadToFile ((NULL, url, fPath, 0, NULL));
}
Your code is not doing any error handling, and your string handling is wrong. Use this instead:
Do note the following comment in the documentation: