Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Grab URL from net to file
#1
I have recently been using the following function to grab a file from the net:

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
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.
Reply


Messages In This Thread
Grab URL from net to file - by eoredson - 10-28-2023, 04:30 AM
RE: Grab URL from net to file - by DSMan195276 - 10-28-2023, 04:45 AM
RE: Grab URL from net to file - by eoredson - 10-28-2023, 04:51 AM
RE: Grab URL from net to file - by eoredson - 10-31-2023, 07:22 AM
RE: Grab URL from net to file - by TerryRitchie - 10-31-2023, 01:43 PM
RE: Grab URL from net to file - by eoredson - 11-01-2023, 05:44 AM



Users browsing this thread: 1 Guest(s)