I have a question regarding how to resume previous downloads using wininet. Here's how I've tried:

...openurl bla, bla...

invoke InternetSetFilePointer,hSession,dwFileSize,0,0
invoke SetFilePointer,hFile,0,FILE_END

...here comes InternetReadFile loop

But when it comes to readfile loop it stall's and seems to continue from given point only after it downloaded everything from the start of the file to this point I wanted it to.

What's the right way to do it? Also is there a way to avoid 100% cpu usage, I know it's because of this readfile loop but is there a way to avoid it?
Posted on 2005-09-14 07:23:28 by asept!c
Mhm, there shouldn't be a 100% CPU usage, ever. I wonder why's that happening. :/

As for the SetFilePointer problem, that could be because the HTTP server you're trying to connect to doesn't support it (for example if it only understands HTTP version 1.0, or simply ignores the Range: header). Try sniffing your connection to see what's going on "under the hood", it may help identify the problem.
Posted on 2005-09-14 09:37:41 by QvasiModo
CPU usage issue was my false reading, my eye slipped when looking at process list, it was something else that caused the 100% usage.

Checking if server supports resume download is somehting that I overseed. Thanks for tips.
Posted on 2005-09-15 05:11:11 by asept!c
Also, rather than use InternetSetFilePointer, you can try sending the appropriate Headers yourself. Read up on http protocol's resume functionality and get your packet sniffer out, hand wininet the headers you want to use and away you go.
Alternatively, you could consider NOT using Wininet and just writing some socket code yourself, perhaps as a blocking thread.. whatever turns you on.
Posted on 2005-09-18 09:32:28 by Homer
Here is a good Tutorial...


I think you will find what you wanted....

Good Enjoy...
Posted on 2005-11-02 23:36:21 by gerard
Yes, Ethereal(http://www.ethereal.com/) is invaluable when working with Wininet.  You should be prepared to check all probable return codes with HttpQueryInfo.  You never know when you might be getting a 300 range redirect.  I have found that turning off automatic redirect handling with the INTERNET_FLAG_NO_AUTO_REDIRECT flag is much more reliable than letting windows do it.  It seems quite buggy to me.
Posted on 2006-04-21 22:53:40 by rdaneel