URLDownloadToFile QtCreator文件未下载

时间:2014-11-19 13:28:20

标签: c++ qt

我今天的问题涉及URLDownloadToFile()与QtCreator的使用。我使用以下代码下载:

HRESULT hRez = URLDownloadToFile(NULL, TEXT(url), TEXT("C:\\image.png"), 0, NULL);
if (hRez != S_OK)
{
    return false;
}

代码运行时没有错误,但文件没有下载。我一直在为我的问题搜索许多解决方案,但没有一个没有成功。我做错了什么?

1 个答案:

答案 0 :(得分:0)

the documentation州:

szFileName:
  A pointer to a string value containing the name or full path of the file to create for the download. 
  If szFileName includes a path, the target directory must already exist.

所以我认为这个参数不仅需要包含路径,还需要包含文件名。例如

HRESULT hRez = URLDownloadToFile(NULL, TEXT(url), TEXT("C:\\downl.tmp"), 0, NULL);
相关问题