描述:
用这个函数复制网页的内容到硬盘,有的时候网络不好或其他原因,这个函数会挂起很长时间,搞得我的程序也挂起了。我想设定一个很小的时间,如果没有下载下来就强迫它返回。不知道怎么实现?
解决方案1:
URLDownloadToFile可以在一个线程里运行,我就这么做过啊。
看一下IBindStatusCallback接口吧。
刚才看了以下,IBindStatusCallback::OnProgress 返回E_ABORT 可以直接终止下载
lpfnCB
Address of the caller's IBindStatusCallback interface. URLDownloadToFile calls this interface's IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called. Implementing IBindStatusCallback::OnProgress allows a caller to implement a user interface or other progress monitoring functionality. It also allows the download operation to be canceled by returning E_ABORT from the IBindStatusCallback::OnProgress call. This can be set to NULL.