-
March 13th, 2011, 12:17 PM
#1
downloading problem
I use URLdownloadtofile to download a 5MB file, but why does it silently stop at 120KB the downloaded part becomes an invalid win32 application ?
Could someone explain ?
I read MSDN and see that this APi only allows download size less than 4GB, I'd like my application to dowload unlimited file size, and wonder how I can do this too.
In my Console appliation, only that function is used, nothing more.
Thank you.
Last edited by somedaysomewhere; March 13th, 2011 at 12:20 PM.
...
-
March 14th, 2011, 05:04 AM
#2
Re: downloading problem
some months back I wrote this small code for grabbing a piece of jpg..
Code:
char szName [180];
char dwnUrl[] = "http://a.imageshack.us/img42/2705/crol.jpg";
HANDLE hF;
URLDownloadToCacheFileA (0, dwnUrl, szName, 180, BINDF_GETNEWESTVERSION, 0);
hF = CreateFileA (szName, GENERIC_READ, 0, 0,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL ,0);
if (hF == INVALID_HANDLE_VALUE)
{
CloseHandle(hF);
return false;
}
if (GetFileSize (hF, 0) == 26053)
{
CloseHandle(hF);
return true;
}
else
{
CloseHandle(hF);
return false;
}
though this code worked fine with larger files. be sure that you are not closing the file handle before downloading completes.
◄◄ hypheni ►►
-
March 14th, 2011, 10:09 PM
#3
Re: downloading problem
Remember URLDownloadToFile only begins the download you must provide a LPBINDSTATUSCALLBACK function to monitor its progress or simply periodically
or loop check the downloaded file size against the size you started to download.
A return of S_OK from URLDownloadToFile only means The download started successfully it does not mean it completed.
Without seeing your code my guess is you get S_OK back and then drop thru to use the file but a large file will still be downloading.
-
March 15th, 2011, 04:37 PM
#4
Re: downloading problem
hi, it works finally, thanks for your guides.
...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|