Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Can';t在Visual C+中使用URLDownloadToFile下载文件+;_C++_Windows_Visual C++_Mfc_Windows Server 2012 R2 - Fatal编程技术网

C++ Can';t在Visual C+中使用URLDownloadToFile下载文件+;

C++ Can';t在Visual C+中使用URLDownloadToFile下载文件+;,c++,windows,visual-c++,mfc,windows-server-2012-r2,C++,Windows,Visual C++,Mfc,Windows Server 2012 R2,这个问题是关于URLDownloadToFileAPI的用法 我在VisualC++ MFC应用程序中使用了 URLDead Load FooS/。在Windows server 2008上,该程序运行良好 示例代码: // invalidate cache, so file is always downloaded from web site // (if not called, the file will be retrieved from the cache if // it's alre

这个问题是关于
URLDownloadToFile
API的用法

我在VisualC++ MFC应用程序中使用了 URLDead Load FooS/<代码>。在Windows server 2008上,该程序运行良好

示例代码:

// invalidate cache, so file is always downloaded from web site
// (if not called, the file will be retrieved from the cache if
// it's already been downloaded.)
DeleteUrlCacheEntry(aCSVDownloadURL);

CallbackHandler callbackHandler;
IBindStatusCallback* pBindStatusCallback = NULL;
callbackHandler.QueryInterface(IID_IBindStatusCallback,
    reinterpret_cast<void**>(&pBindStatusCallback));

HRESULT hr = URLDownloadToFile(
    NULL,   // A pointer to the controlling IUnknown interface
    DownloadURL,
    FileName, // Filename to save the downloaded file in local
    0,      // Reserved. Must be set to 0.
    pBindStatusCallback // Callback interface to catch the download response; basically the file name
);

if (hr == S_OK)
{
    cout << "Download OK" << endl;
}
else if (hr == E_OUTOFMEMORY)
{
    cout << "The buffer length is invalid, or there is insufficient memory to complete the operation." << endl;
} else if (hr == INET_E_DOWNLOAD_FAILURE)
{
    cout << "The specified resource or callback interface was invalid." << endl;
}
else {
    cout << "Other error" << endl;
}
//使缓存无效,所以文件总是从网站下载的
//(如果未调用,则在以下情况下将从缓存中检索文件:
//已经下载了。)
DeleteUrlCacheEntry(aCSVDownloadURL);
CallbackHandler CallbackHandler;
IBindStatusCallback*pBindStatusCallback=NULL;
callbackHandler.QueryInterface(IID\u IBindStatusCallback,
重新解释强制转换(pBindStatusCallback)(&pBindStatusCallback));
HRESULT hr=URL下载文件(
NULL,//指向控制IUnknown接口的指针
下载网址:,
FileName,//FileName将下载的文件保存在本地
0,//保留。必须设置为0。
pBindStatusCallback//用于捕获下载响应的回调接口;基本上是文件名
);
如果(hr==S_正常)
{

cout“blow error”是一个打字错误,还是这种错误的实际术语…?哦:(打字错误,很快就会更新。您需要显示调用该函数的代码。@AlexK:谢谢您的评论。在说明中添加了示例代码。我猜是某种防火墙阻止了您的连接。”下载失败(连接中断)。“
URLDownloadToFile
与.NET没有任何关系