Allow backround events while using URLDownloadToFile API
Posted on 2003-03-23
I'm trying to implement an update feature for my program. Part of that requires launching an Updater.exe file, which in turn downloads the new version of the program I'm trying to update. To download the new program, I've been using the URLDownloadToFile API. It works, but there are 1-2 problems with it.
The main one is that once the code executes to download a file using this API, all other events HALT, such that if the file is big, a user may think the Updater is frozen, and indeed it has to be Forced to close until it finishes the download...( For example, moving the form, changing focus, clicking other controls, any event within the form)
I tried using DoEvents, but that doesn't really help, as control passes to the API on that line of code, so I can only allow events before or after the download, but NOT during the download...
One possible solution would be a progress bar such that the end-user can see that its doing something, but thats the second issue. The ONLY way that I could find that *might* allow showing a progress bar during download is using the pCaller and lpfnCB fields of the API. But from the looks of it, that only works with a Microsoft ActiveX Control...which this is not, + I would need some help on how to use those.
My goal with this is to make a small, light Updater app that basically downloads a file WITHOUT "freezing" during the download, that shows progress of download.
The download itself would be roughly 260 Kb - 500 Kb, maybe 1-3 times a week.
The main app would check a remote text file, determine if there's an update, if there is launch this updater.exe, which then downloads the new program, kills the current program, and launches the new one.
Any tricks for using this API, or suggestions of better ones appreciated...