Compartilhar via


CeOpenStream (EDB) (Windows CE 5.0)

Send Feedback

This function is used to open a stream object on a CEVT_STREAM typed property.

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

HANDLE CeOpenStream(HANDLEhDatabase,CEPROPIDpropid,DWORDdwMode);

Parameters

  • hDatabase
    [in] A handle to the database that is positioned on the desired row in which you want to open the stream object.
  • propid
    [in] The property ID of the property on which to open the stream object. This property must be a CEVT_STREAM type.
  • dwMode
    [in] The access mode, which can be either of the following flags:
    • GENERIC_READ

      Provides read access to the stream.

    • GENERIC_WRITE

      Provides both write and read access to the stream.

Return Values

A handle to the stream object indicates success; a return value of INVALID_HANDLE_VALUE 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 one of the following:
  • dwMode doesn't contain GENERIC_READ or GENERIC_WRITE.
  • propid is not a CEVT_STREAM typed property.
  • propid is not a valid property in the database.
ERROR_INVALID_HANDLE Indicates that hDatabase 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_ACCESS_DENIED Indicates one of the following:
  • The stream is compressed. A stream can't be opened if it is compressed.
  • Another stream on this database handle is open. Only one stream at a time can be opened for write access on a particular database handle.
  • There is no value assigned to the property (it is NULL). The stream cannot be opened for read; it can only be 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 object before doing anything else on the parent database.

Remarks

A stream handle allows you to efficiently read and write the contents of a stream-typed property. A stream-typed property can be very large, such as an image or an e-mail attachment, and it would be inefficient to load the entire contents of the stream into memory at once. For smaller binary properties, you should use the CEVT_BLOB or the CEVT_LPWSTR typed property.

The database must be positioned on the desired row in which you want to open the stream.

The following stream functions can be used once a stream object is opened:

Only one stream can be opened for write access at a time for a single database handle. If you open a stream for write access, you must remember to save the changes that you have made to the stream by calling the CeStreamSaveChanges function.

A stream that has been created with the flag DB_PROP_COMPRESSED can't be opened on a CEVT_STREAM property. Instead, you must use the CeWriteRecordProps (EDB) function.

A stream can't be opened for read if there is no value assigned to the property. However, the stream can be opened for write.

If the seek position of the database is changed, then the stream handle is abandoned.

The handle returned from this function must be closed by using the CloseHandle function.

Requirements

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

See Also

CeStreamRead (EDB) | CeStreamWrite (EDB) | CeStreamSaveChanges (EDB) | CeStreamSetSize (EDB) | CeStreamSeek (EDB) | CeWriteRecordProps (EDB)

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.