CeStreamWrite (EDB)

A version of this page is also available for

Windows Embedded CE 6.0 R3


This function writes data into a stream.


BOOL CeStreamWrite(
  HANDLE hStream,
  LPBYTE lprgbBuffer,
  DWORD cbWrite,
  LPDWORD lpcbWritten


  • hStream
    [in] Handle to the stream object. The handle is obtained with the CeOpenStream (EDB) function.
  • lprgbBuffer
    [in] Pointer to the buffer that contains the data to write.
  • cbWrite
    [in] Number of bytes to write from lprgbBuffer.
  • lpcbWritten
    [out] On return, contains the actual number of bytes written. This value can be less than the value specified by cbWrite. This parameter can be set to NULL.

Return Value

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

Return Value Description


Indicates ones of the following:

  • The stream was not opened with GENERIC_WRITE.
  • The CeStreamSaveChanges (EDB) function has been called on a stream opened for write, and then the stream has become read-only and must be re-opened for write.


The hStream parameter is set to NULL or equal to INVALID_HANDLE_VALUE.


The lprgbBuffer parameter is set to NULL.


The database from which the stream object was opened had its seek position changed. To prevent this, open a stream, perform the operations, and then close the stream before doing anything else in the parent database.


When using this function, the data is written at the current seek position. You can adjust the seek position of a stream with the CeStreamSeek (EDB) function. If the data is written to the end of the stream, the stream grows in size. To write to a stream, you must have specified the GENERIC_WRITE flag when opening the stream with CeOpenStream.

After the write has completed successfully, the current seek position is incremented by the number of bytes written. To save changes made with this function, call CeStreamSaveChanges. Data written to a stream overwrites data currently in the stream, but it does not truncate the stream on completion. To truncate the stream, use the CeStreamSetSize (EDB) function. If writing data to a stream for the first time or growing a stream, it is generally more efficient to use CeStreamSetSize to set the stream size, and then write to it.


Header windbase.h
Library coredll.lib
Windows Embedded CE Windows CE 5.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also


EDB Functions
CeOpenStream (EDB)
CeStreamSaveChanges (EDB)
CeStreamSeek (EDB)
CeStreamSaveChanges (EDB)
CeStreamSetSize (EDB)