关于使用 winhttp api 进行文件下载的问题

jin517266098 2016-10-13 09:04:08
我需要下载个文件,然后在UI表示过程中的下载速度。

在 WinHttpReceiveResponse 成功后, 开始下载文件。

我对这些 api 的了解也不是太深,我之前是任务所谓的下载时间应该是花在 WinHttpReadData 上的。但是通过打 log 发现调用 WinHttpReadData 前和调用 WinHttpReadData 后好多次的时间间隔都为0, 虽然读取的buff不大,但是也不会是 0 毫秒吧。

请了解这些 api 的用法的人帮忙解答一下吧,所谓的 “下载时间” 到底会花在哪些函数上呢?
...全文
194 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2016-10-14
  • 打赏
  • 举报
回复
URLDownLoadToFile Downloads bits from the Internet and saves them to a file. The client can optionally be notified of progress by means of a notification callback. HRESULT URLDownloadToFile( LPUNKNOWN pCaller, // Caller's controlling IUnknown LPCWSTR szURL, // Pointer to URL to be downloaded LPCTSTR szFileName, // Pointer to file name DWORD dwResv, // Reserved for future use LPBINDSTATUSCALLBACK lpfnCB // Caller's IBindStatusCallback ); Parameters pCaller [in] Pointer to the caller's controlling IUnknown. If the caller is not an ActiveX component, this value may be set to NULL. szURL [out] Pointer to the URL to be downloaded. Cannot be NULL. szFileName [out] Pointer to the name of the file returned by this function. The user should pass a buffer to be filled and, preferably, use MAX_PATH to allocate the maximum path size. dwResv [in] Reserved for future use; must be zero. lpfnCB [in] Pointer to the caller's IBindStatusCallback interface. Can be NULL. Return Values This function returns the same values as IBindHost::MonikerBindToStorage. Remarks URLDownloadToFile calls the caller's IBindStatusCallback interface to provide notifications during the binding process. In particular, URLDownloadToFile calls IBindStatusCallback::OnProgress to report the ongoing status of the download. The caller does not need not implement any of the notification callbacks for the function to succeed, but doing so allows the client to receive notifications, if interested, and also allows downloads to be canceled by returning E_ABORT from the OnProgress call. If pCaller is non-NULL, the caller is a COM object that is contained in another component, such as an ActiveX Control in the context of an HTML page. In this case, the function attempts the download in the context of the ActiveX client framework and allows the caller's container to receive callbacks on the progress of the download. QuickInfo Windows NT: Use version 5.0 or later. Windows: Unsupported. Windows CE: Unsupported. Header: Declared in urlmon.h. See Also IBindStatusCallback, IBindStatusCallback::OnProgress

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧