Discussion:
Restarting a download with InternetSetFilePointer?
(too old to reply)
Cameron Fitzhugh
2006-10-14 00:38:24 UTC
Permalink
I have a large download so I wanted to download it in pieces. After
InternetOpenUrl on an FTP site (ftp://ftp.xxx.xxx/...) I tried to restart
downloading where my last session ended, but InternetSetFilePointer gave a
return code of -1, and then GetLastError returned 0 (zero). A subsequent
InternetReadFile begins at the beginning of the remote file.

Am I using the wrong method to restart a download? There's lots of
shareware out there that says it can restart downloads, so presumably it is
possible.

I tried this same program on an HTTP site, again InternetSetFilePointer gave
a return code of -1, but in this case, GetLastError returned 12016,
ERROR_INTERNET_INVALID_OPERATION.

So, can you help me with restarting downloads in a C++ program? I'm on XP,
up to date with all high-priority updates.

Thanks,
Cameron
Cameron Fitzhugh
2006-10-22 11:07:25 UTC
Permalink
MSDN says InternetSetFilePointer is not for FTP:

hFile [in] Handle returned from a previous call to InternetOpenUrl
(on an HTTP or HTTPS URL) or HttpOpenRequest (using the GET or HEAD
HTTP verb and passed to HttpSendRequest or HttpSendRequestEx).
This handle must not have been created with the INTERNET_FLAG_DONT_CACHE
or INTERNET_FLAG_NO_CACHE_WRITE value set.
Post by Cameron Fitzhugh
I have a large download so I wanted to download it in pieces. After
InternetOpenUrl on an FTP site (ftp://ftp.xxx.xxx/...) I tried to restart
downloading where my last session ended, but InternetSetFilePointer gave a
return code of -1, and then GetLastError returned 0 (zero). A subsequent
InternetReadFile begins at the beginning of the remote file.
Am I using the wrong method to restart a download? There's lots of
shareware out there that says it can restart downloads, so presumably it is
possible.
I tried this same program on an HTTP site, again InternetSetFilePointer gave
a return code of -1, but in this case, GetLastError returned 12016,
ERROR_INTERNET_INVALID_OPERATION.
So, can you help me with restarting downloads in a C++ program? I'm on XP,
up to date with all high-priority updates.
Thanks,
Cameron
Loading...