Announcement

Collapse
No announcement yet.

URLDownloadToFile - More Stuff to Know

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • URLDownloadToFile - More Stuff to Know

    I typically use this for simple file downloads:

    Code:
    iResult = URLDownloadToFile(Nothing, (OnlineImageURL$), (LocalImageName$), 0, Nothing)
    But as I read MSDN tonight, URLDownloadToFile arguments can apparently be set to enable receipt of callbacks on the progress of the download. In the past, I'd thought progress callbacks were not available with URLDownloadToFile. It seems I was wrong. I've not yet searched for code to demonstrate the callback option.

    It seems that the two "Nothing" arguments disable any such callbacks and the API then becomes a synchronous download instead of an asynchronous download. In that case, the app completes the code above before moving to the next line in the app. This code seems to confirm that, where bigfile.txt is a large file and the result is not displayed until the download completes, seconds later, not immediately.

    Code:
    #Include "win32api.inc"
    #Include "wininet.inc"
    Function PBMain() As Long
       Local iResult As Long
       DeleteURLCacheEntry("http://www.garybeene.com/files/bigfile.txt")
       iResult = URLDownloadToFile(Nothing, "http://www.garybeene.com/files/bigfile.txt", "bigfile.txt", 0, Nothing)
       ? Str$(iResult)
    End Function
    Does anyone know differently than what I have asserted?

  • #2
    As I understand it, the callback is only available if URLDownloadToFile is called from an object. The first and last parameters need to be pointers to interfaces.

    So yes, the only way it could be asynchronous is through an object interface.

    Comment


    • #3
      @Gary,

      I already posted code three years ago explaining you how to use a callback with UrlDownloadToFile:

      See: https://forum.powerbasic.com/forum/u...tcp#post764578

      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


      • #4
        Howdy, Jose!

        Yep, thanks for the reminder (and the code of course).

        Comment

        Working...
        X