InternetReadFile buffer size

Giganews Newsgroups
Subject: InternetReadFile buffer size
Posted by:  Mo (marabo…@hotmail.com)
Date: 29 Sep 2006

Hello All,
i have a basic question, i am using InternetReadFile() to download
images from a server, the images size is variant, currently i am using
a 4K buffer and passing a ptr to it in InternetReadFile

BYTE bDownloadBuffer[4096];
InternetReadFile(hResourceHandle, bDownloadbuffer,
sizeof(bDownloadbuffer), &dwRead )

it seems to be working fine, i am downloading images as big as 30k,
however, i want to avoid getting In suffiecient buffer error so should
i make my buffer size depending on the image size (i can get the image
size using HttpQueryInfo(hHttpOpenRequest, HTTP_QUERY_CONTENT_LENGTH
.....))

this means i have to make my download buffer as big as 30k sometimes,
on the stack (in a mobile device is that a good idea)?

i dont understand how InternetReadFile actually works, msdn help
states that "WinINet attempts to write the HTML to the lpBuffer buffer
a line at a time" so does that mean even if the image size is 30k and
my buffer size is 4k, InternetReadFile will not fail because my buffer
is small, and it will read 4k each time until the image is fully
downloaded?

Appreciate the help
Mo

Replies