After opening a Windows CE database, the seek pointer is positioned at the first record according to the selected sort order.
The CeReadRecordProps function reads properties from the record where the seek pointer is currently positioned. When calling CeReadRecordProps, indicate the properties to be read by specifying an array of property identifiers. Also specify the buffer into which the function is to write the property information, and a value indicating the size of the buffer. If you specify the CEDB_ALLOWREALLOC flag, the system will reallocate the buffer if it is too small to hold the property information. Note that the system stores records in compressed format and must decompress records as they are read. For efficiency, you should read all of the desired properties in a single call rather than in several separate calls.
When the property is read successfully, the property information is copied into the specified buffer as an array of CEPROPVAL structures, and the function returns the record's object identifier.
If the system cannot find a requested property in the given record, the CEPROPVAL structure for that property receives the CEDB_PROPNOTFOUND flag. All of the variable size data, such as strings and BLOBs, are copied to the end of the buffer. The CEPROPVAL structures contain pointers to this data.
If you specified the CEDB_AUTOINCREMENT flag when opening the database, CeReadRecordProps increments the seek pointer.
The following code example demonstrates how to read properties from the database using the autoincrement and reallocation flags.
CEOID objId; // object identifier; use for db, each record
HANDLE hDb; // handle to the database
WORD cProps; // count of properties returned by Read operation
LPBYTE pBuf = NULL; // no init size; let CeReadRecordProps realloc
DWORD cbBuf; // count of bytes in buffer
...
hDb = CeOpenDatabase(&objId, // tmp location for the database id
szDbName, // database name
0, // sort order; 0 indicates ignore
CEDB_AUTOINCREMENT,
NULL); // window handle for notifications
// perform error checking on hDb handle before continuing...
while (objId = CeReadRecordProps(hDb,
CEDB_ALLOWREALLOC,
&cProps, // return count of properties
NULL, // retrieve all properties
&pBuf, // buffer to return prop data
&cbBuf)) // count of bytes in pBuf1
{ // record is now available in pBuf1
// add code here to manipulate the props in this record
}
// at this point, all records have been read from the database
CloseHandle(hDb);