Hi,
The following is a code that I use to download a file from a given url
into a given fille location. If one is to copy that code, paste it on
a new vb6 moduel, and then run it (i.e., execute the subroutine Main),
the file vbm_demo.zip will be downloaded from the folder
http://www.vb2themax.com/vbmaximizer/files to the local C Drive. My
question is how does one can embed a download progress measure into
this downloading process. I managed to learn that there is a progress
event associated with the urlmon.dll, but I don't know how to make it
work. Also, I tried to go to the project refernxes and include the
urlmon.dll in my project, but it does not seem to wotk. I get and
error message telling me ' can not add refernce to the specidied
file'. I believe that this inability to add the urlmon.dll to the
project is part of the problem. Here is the code :
Public Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As
String, _
ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
' Note that this file is 2M, so you might want to try with something
simpler
Sub Main ()
Dim URL As String
Dim localFileName As String
URL = "http://www.vb2themax.com/vbmaximizer/files/vbm_demo.zip"
localFileName = "c:\vbm_demo.zip"
DownLoadAfile URL, localFileName
End Sub
Function DownLoadAfile(URL, localFileName)
Dim errcode As Long
errcode = URLDownloadToFile(0, URL, localFileName, 0, 0)
If errcode = 0 Then
MsgBox "Download ok"
Else
MsgBox "Error while downloading"
End If
DownLoadAfile = errcode
End Function
If you have any suggestions as to how I keep track of the quantity of
bytes downloaded at different point in times, then I would be greatly
appreciative if you can share it with me.
Thank you in advance
Avi
BeastFish - 06 Mar 2004 22:15 GMT
Well, when I do a "live update" feature, I generally use wininet.dll's
InternetReadFile function (get the filesize and download in chunks, thus
allowing for showing progress). If you want to show the progress while
using URLDownloadToFile, you'd need to impliment the callback interface.
Eduardo Morcillo has a sample of doing this on his website
http://www.mvps.org/emorcillo/vb6/inet/adl.shtml
HTH
> Hi,
>
[quoted text clipped - 47 lines]
>
> Avi
Randy Birch - 07 Mar 2004 01:24 GMT
As I recall, this particular API's callback requires the use of a typelib in
order to monitor the status. See http://www.mvps.org/emorcillo/

Signature
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
: Hi,
:
[quoted text clipped - 47 lines]
:
: Avi
Avi - 07 Mar 2004 19:19 GMT
Hi
Big Thank you to Beastfish and Randy Birch -- I appreciate your
willingness to help and the time you took to prvide me with different
alternatives. I now managed to display a progress bar while
downloading.
Take care
Avi