Providing Buffers

Top  Previous  Next

 

Buffers must be provided to called functions to retrieve complex information. From a logical point of view this information can be:

 

A text string (Ansi or Unicode)
A simple structure with a fixed size
A structure with dynamically sized components, e.g. the image of a bitmap file
A nested structure with dynamic substructures
An array of strings, structures, interfaces, fake objects, ... or simple values
Just a chunk of memory to provide space for other parameters

 

When handling buffers you will be confronted with the following values:

 

Before the call

 

The address of the buffer)
Buffer size information
The size of the buffer in bytes
The size of the buffer in number of entries in case of arrays
Length information in case of a text string

 

After the call

 

Information if the call succeeded, in case it didn't you must figure out if the buffer size was the problem
The size of the returned value in the buffer (after call)
The number of valid entries returned in the buffer
Sometimes the size required to retrieve the requested information
Sometimes the size required to retrieve the next bit or all available information

 

For the call