CeStreamWrite (EDB) (Windows CE 5.0)

Send Feedback

This function is used to write data into a stream.

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

BOOL CeStreamWrite(HANDLEhStream,LPBYTElprgbBuffer,DWORDcbWrite,LPDWORDlpcbWritten);

Parameters

  • hStream
    [in] A handle to the stream object. The handle is obtained by using the CeOpenStream (EDB) function.
  • lprgbBuffer
    [in] A pointer to the buffer that contains the data to write.
  • cbWrite
    [in] The 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 the cbWrite 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_ACCESS_DENIED 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 becomes read-only and must be re-opened for write.
ERROR_NO_MORE_ITEMS Indicates that the database from which the stream object was opened had its current row seek position changed. 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 written at the current seek position of the stream. You can adjust the seek position of a stream by calling the CeStreamSeek (EDB) function. If the data is written to the end of the stream, then the stream grows in size. In order to write to a stream, you must have specified the GENERIC_WRITE flag when opening the stream using CeOpenStream.

After the write has successfully completed, the current seek position of the stream is incremented by the number of bytes written. To save the changes that are made to a stream using this function, you must call the CeStreamSaveChanges function. Data written to a stream overwrites data currently in the stream, but it does not truncate the stream on completion of the write. 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.

Requirements

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

See Also

CeOpenStream (EDB) | CeStreamSaveChanges (EDB) | CeStreamSeek (EDB) | CeStreamSaveChanges (EDB) | CeStreamSetSize (EDB)

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.