The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.


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 page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Layers an IStorage interface onto an IStream object.

Header file:


Implemented by:


Called by:

Client applications and service providers

HRESULT HrIStorageFromStream(
  PIID lpInterface,
  ULONG ulFlags,
  LPSTORAGE FAR * lppStorageOut


[in] Pointer to the IUnknown object implementing IStream.


[in] Pointer to the interface identifier (IID) for the stream object. Any of the following values can be passed in the lpInterface parameter: NULL, IID_IStream, or IID_ILockBytes. Passing NULL in lpInterface is the same as passing IID_IStream.


[in] Bitmask of flags that controls how the storage object is to be created relative to the stream. The default setting is STGSTRM_RESET, which gives the storage object read-only access and starts it at position zero of the stream. The following flags can be set in any combination, except as noted:


Creates a new storage object for the stream object. This flag cannot be set if the STGSTRM_RESET flag is set.


Starts storage at the current position of the stream. This flag cannot be set if the STGSTRM_RESET flag is set.


Allows the calling service provider to write to the returned storage. This flag cannot be set if the STGSTRM_RESET flag is set.


Starts storage at position zero. This flag cannot be set if any other flag is set.


[out] Pointer to a pointer to the returned IStorage object.


The call succeeded and has returned the expected value or values.

Message store providers support the HrIStorageFromStream function using the IStorage interface for attachments. Store providers must implement the IStream interface. HrIStorageFromStream provides the IStorage interface for the IStream object. It is possible to pass either an ILockBytes or an IStream interface in lpUnkIn.