If I'm downloading a file via URLDownloadToFileA() how can I print something to the screen whilst it is downloading?
If I have something after the function call, it obviously won't run until the function returns.
Printable View
If I'm downloading a file via URLDownloadToFileA() how can I print something to the screen whilst it is downloading?
If I have something after the function call, it obviously won't run until the function returns.
Use threads.Quote:
Originally Posted by eth0
If you were thinking of displaying the progress of the download then this function dosen't provide anyway to do that.
That was the plan.
Can you tell me a function which would make life easier?
The idea was to put a spinning bar in the command line to start with, and then maybe try replacing that with percentage figure later.
Was the URLDownloadToFile function that you used like this?
If thats the function you used then you can place your code to update the progress in a callback routine and pass it's pointer as the last paramater.Code:HRESULT URLDownloadToFile(
LPUNKNOWN pCaller,
LPCSTR szURL,
LPCSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);
I've found URLDownloadToFile to be rather flaky. I've previously posted code that downloads a file to memory using wininet.
As mentioned by Q1024, you can pass a pointer to an IBindStatusCallback COM interface as the last argument to URLDownloadToFile. This is a little more complicated to implement in C (sample here) than C++ (sample here - program 4).