When I download files using WinInet functions sometimes
(especially when files are too large) I must wait m-m-m some time.
How can I detect size of downloading file and how much
bytes have been downloaded?
Posted on 2002-08-02 11:09:45 by Mike
I have never used WinInet but if you are doing this with HTTP the field Content-Length would be set to a value. There is a way to get the information from the header using WinInet right?

Heh, I guess I wasn't much help ... maybe I need to look at the WinInet stuff

In the process of looking up WinInet................
Posted on 2002-08-02 14:03:12 by gorshing
What about HttpQueryInfo and specify HTTP_QUERY_CONTENT_LENGTH as the dwInfoLevel( second param ).

I could be leading you in the wrong direction....like I said I've never touched WinInet classes.
Posted on 2002-08-02 14:13:37 by gorshing
I use WinInet only one week. In WinSock I send request
"HEAD http://www.hostname.com/index.htm HTTP/1.0",13,10
and then in it I search for string
Content-Length: 1066
Now I must do the same in WinInet.
I've tried to write
invoke HttpQueryInfo, hUrl, 0, offset szHeader, 256, 0
but it is not working.

Thanks, Mike
Posted on 2002-08-04 05:06:35 by Mike
After much messing about I finally got this to work see below:

fileUrl db "http://www.smidgeonsoft.prohosting.com/download/TOPTOBOT.ZIP",0
msgErr2 db "Can't determine size of download", 0
mcap db "Error",0

LOCAL Buffer[1024]: BYTE
invoke InternetOpenUrl, hSession, addr fileUrl, NULL, NULL, INTERNET_FLAG_RELOAD, NULL
mov hUrl, eax
mov eax, FALSE

mov eax, 1024
mov sz, eax
invoke HttpQueryInfo, hUrl, HTTP_QUERY_CONTENT_LENGTH, addr Buffer, addr sz, 0
.if eax == FALSE
invoke MessageBox, NULL, addr msgErr2, addr mcap, MB_OK
PrintString Buffer
PrintDec sz

Hope this works. Now all you need to do is parse the Buffer (which is a decimal string into a variable/register).

Hope this helps
Posted on 2002-08-25 11:08:30 by timkempster
As far as I know, HEAD is not supported by some older httpd's. I would use Content-Length instead. Sometimes it is also not supplied, well then you won't know the total size anyway (until the connection closes).
Posted on 2002-08-25 13:09:34 by comrade