It is only necessary to call
GetSize
and
GetData
once, before you start the loop. You can then use the returned values to walk the buffer writing your fixed size chunks. Something like:
int chunksize = 1024; DWORD dwBytesWritten;
int arraySize = btMemArray->GetSize();
byte* pByte = btMemArray->GetData();
while (arraySize > 0)
{
if (arraySize < chunksize)
{
chunksize = arraySize; }
WriteFile(hFile, pByte, chunksize, &dwBytesWritten, NULL);
pByte += chunksize;
arraySize -= chunksize; }