如何使用进度条在VB6中下载多个文件? [英] How to download multiple files in VB6 with progress bar?

查看:122
本文介绍了如何使用进度条在VB6中下载多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从VB6应用程序下载多个文件(大多是图像)。目前我使用URLDownloadToFile,但它一次只允许一个文件,没有进度条。我想下载多个文件和进度条。请帮忙。感谢提前。

I want to download multiple files (mostly images) from VB6 application. presently i m using URLDownloadToFile but it allows only one file at a time and there is no progress bar. I want to download multiple files and with progress bar. please help. thanks in advance.

我现在的代码:

Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True


推荐答案

您想要异步下载文件,以便您的VB代码在下载时继续执行。 是一个鲜为人知的方法,使用本机VB6,使用 AsyncRead 方法 - 不需要API调用。

You want to download the file asynchronously, so that your VB code continues executing while the download happens. There is a little-known way to do this with native VB6, using the AsyncRead method of UserControl and UserDocument objects - no need for API calls.

这是一个很好的多个同时下载的解释和VB6代码,从着名的VB6大师 Karl Peterson 。 AsyncReadProgress事件为您提供BytesRead和BytesMax,它将允许您显示一个进度条。

Here's an excellent explanation and VB6 code for multiple simultaneous downloads, from the renowned VB6 guru Karl Peterson. The AsyncReadProgress event gives you the BytesRead and BytesMax, which will allow you to display a progress bar.

这篇关于如何使用进度条在VB6中下载多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆