CeStreamRead (EDB) (Windows CE 5.0)

Send Feedback

This function is used to read data from a stream.

This function does not work with CEDB databases. For more information about CEDB, see CEDB Reference.

BOOL CeStreamRead(HANDLEhStream,LPBYTElprgbBuffer,DWORDcbRead,LPDWORDlpcbRead);

Parameters

  • hStream
    [in] A handle to the stream object. The handle is obtained by using the CeOpenStream (EDB) function.
  • lprgbBuffer
    [out] A pointer to the buffer into which data is written as it is read.
  • cbRead
    [in] The number of bytes to read from the stream.
  • lpcbRead
    [out] On return, contains the actual number of bytes read. This value can be less than the value specified by the cbRead parameter. This parameter can be NULL.

Return Values

TRUE indicates success. FALSE indicates failure. To get extended error information, call GetLastError. The following table lists possible values returned by GetLastError:

Return Value Description
ERROR_INVALID_PARAMETER Indicates that lprgbBuffer is NULL.
ERROR_INVALID_HANDLE Indicates that hStream is NULL or equal to INVALID_HANDLE_VALUE.
ERROR_KEY_DELETED Indicates that the parent row of the stream object has been deleted. This can happen only if the stream object was opened for read access. When a stream is opened for write access, the parent row is locked for write access, which prevents the row from being deleted.
ERROR_NO_MORE_ITEMS Indicates that the database from which the stream object was opened had its current row seek position. To prevent this, you should open a stream, perform the operations, and then close the stream before doing anything else on the parent database.

Remarks

When using this function, the data is read from the current seek position of the stream. You can adjust the seek position of a stream by using the CeStreamSeek (EDB) function. If the requested amount of data to read, specified by cbRead, cannot be entirely read, this function still succeeds, returning the actual number of bytes read in the pcbRead parameter.

In order to read from a stream, you must have specified the GENERIC_READ flag when opening the stream using the CeOpenStream function. While a stream is opened for read access, the parent row is not locked, and other threads can simultaneously make changes to the same stream object. Other threads can also make changes to the parent row of the stream object, including deleting the parent row. If a stream is opened for GENERIC_WRITE, then the row will be locked and, although no other thread can make changes to the stream, other threads can read the old data in the stream. Once the stream that is writing saves its changes, the new data will be visible to other threads.

To ensure that a read can examine data without that data being affected by a concurrent WRITE operation, you can protect the read by reading within a transaction at the Repeatable Read isolation level. For more information, see EDB Isolation Levels.

After the read has successfully completed, the current seek position of the stream is incremented by the number of bytes read.

Requirements

OS Versions: Windows CE 5.0 and later.
Header: Windbase.h.
Link Library: Coredll.lib.

See Also

CeOpenStream (EDB) | EDB Isolation Levels

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.