GetBlock


The GetBlock method reads block of data present in internal buffer and returns number of bytes actually read. File position is moved forward by the number of bytes read.
C++
long GetBlock(
  BYTE **ByteBuffer,          // variable that receives pointer to data
  long NumberOfBytes          // number of bytes to read
);

Parameters

ByteBuffer
Variable that receives pointer to data.
On completion *ByteBuffer points to beginning of data block in internal buffer.
NumberOfBytes
Number of bytes to read from internal buffer.
If this parameter is -1 entire data block present in internal buffer is read.

Return Values

If the method succeeds, the return value is the number of bytes actually read.
The return value is 0 if end of file was encountered or data transfer is unbuffered.
If the method fails, the return value is failure code and error code is set. Call GetError to get error code.

Remarks

Method returns the number of bytes actually read, which may be less than expected if end of file is encountered prematurely or there is less data in buffer. If data transfer is unbuffered (active buffer size is set to 0) no data is read and method returns 0.

Method reads data actually present in buffer regardless of its size; in other words you cannot read more data then is currently available in buffer. The only exception is when data buffer is empty; in such case entire buffer is filled with data from file and returned to user. In any case file position is moved forward by the number of bytes returned to user. Buffer contents returned in *ByteBuffer is valid only until next read or write operation.

Please note that data is not transferred to user at all; on completion *ByteBuffer points to data block in internal buffer and data is accessed directly from buffer; care must be taken, however, to access buffer properly, within its bounds.

See Also

GetBlockSize, GetBit, GetByte, GetShort, GetLong, GetFloat, GetDouble, GetText, GetUnicodeText, GetVariant, GetBinary, Reading and Writing Data