Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The OpenPropertymethod opens a stream property for a PIM item (for example, a picture). The length (size) of the stream is limited only by the amount of available storage memory.
Syntax
HRESULT OpenProperty( CEPROPID propID, DWORD dwMode, IStream ** ppStream ) |
Parameters
- propID
-
[in] The unique Object Identifier (OID) of the stream property to open. For more information, see CeOpenStream (EDB). For information on CEPROPID, see CeOpenStream (EDB).
- dwMode
-
[in] Bitmask of flags that indicates the stream access mode used to open the stream. The following table shows the values the parameter can take.
Option Description GENERIC_READ
Read access to the stream.
GENERIC_WRITE
Write access to the stream.
- ppStream
-
[out] Reference to the IStreamproperty.
Return Value
This method returns the standard values HRESULT_FROM_WIN32(GetLastError()), E_INVALIDARG, and S_FAIL, as well as the following:
- S_OK
-
The method completed successfully.
Remarks
Streams behave differently depending on whether the item has been saved. You must call IStream::Commit(note the parameter of zero) on the stream before calling IItem::Saveon the item. If you do not, then the Item might not be saved. This depends on whether you have previously saved the item.
The following IStreammethods return the error value E_NOTIMPL: IStream::LockRegion, IStream::UnlockRegion, IStream::Revert, IStream::Clone, and Stat.
IItem::OpenPropertyreturns E_ACCESSDENIEDif you attempt to open a second stream on the same property, or if you attempt to open a 0-byte stream with only the GENERIC_READflag set.
Code Example
The following code example demonstrates how to use OpenProperty.
Note: |
---|
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them. |
Copy Code | |
---|---|
HRESULT OpenPropertyExample(IItem *pItem, LPBYTE pbStore, ULONG cbStore) { HRESULT hr = E_FAIL; IStream * pStream = NULL; CEPROPID propid = PIMPR_BODY_BINARY; ULONG cbWritten = 0; // Write the byte data passed into the body property of the IItem. hr = pItem->OpenProperty(propid, GENERIC_READ | GENERIC_WRITE, &pStream); hr = pStream->Write(pbStore, cbStore, &cbWritten); // Commit the stream. hr = pStream->Commit(0); // Save the stream to the underlying datastore. hr = pItem->Save(); pStream->Release(); return hr; } |
Requirements
Header | pimstore.h |
Library | Pimstore.lib |
Windows Mobile | Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later |