10-28-2023, 04:30 AM
I have recently been using the following function to grab a file from the net:
but what I want to know if there is a way to determine the progress of the download if it is a very large file!?
Thanks, Erik.
Code: (Select All)
Rem Program to grab file from url PD 2023.
Declare Dynamic Library "urlmon"
Function URLDownloadToFileA% (ByVal pCaller As Long, szURL As String, szFileName As String, Byval dwReserved As Long, Byval lpfnCB As Long)
End Declare
Declare Dynamic Library "kernel32"
Function GetLastError& ()
Function FormatMessageA& (ByVal f As Long, f$, Byval e As Long, Byval d As Long, g$, Byval s As Long, h$)
End Declare
Dim Shared ErrorBuffer As String * 260
Call GrabURL
End
' expiremental url grab.
Sub GrabURL
' URL to grab (page or a file)
URL$ = "http://www.filegate.net/pub/oredson/emc3.zip"
' File to save URL as
URLfile$ = "emc3.zip"
' display files
Print "URL: "; URL$
Print "File: "; URLfile$
' Download it. Returns 0 if started.
a& = URLDownloadToFileA%(0, URL$ + Chr$(0), URLfile$ + Chr$(0), 0, 0)
If a& = 0& Then
Print "Download started."
End If
If a& > 0& Then
y& = FormatMessageA&(&H1200, "", a&, 0, ErrorBuffer$, 260, "")
Var1$ = "Error 0x" + Hex$(a&): Print Var1$
If y& > 2 Then
Var2$ = Left$(ErrorBuffer$, y& - 2): Print Var2$
End If
End If
End Sub
Thanks, Erik.