Opens an existing storage object with the specified name according to the specified access mode.

HRESULT OpenStorage(

const wchar_t * pwcsName,
//Points to the name of the storage object to open
IStorage * pstgPriority,
//Points to previous opening of the storage object
DWORD grfMode,
//Access mode for the new storage object
SNB snbExclude,
//Points to a block of stream names in the storage object
DWORD reserved,
//Reserved; must be zero
IStorage ** ppstg
//Points to opened storage object



[in]Points to the name of the storage object to open. It is ignored if pstgPriority is non-NULL.


[in]If the pstgPriority parameter is not NULL, it is a pointer to a previous opening of an element of the storage object, usually one that was opened in priority mode. The storage object should be closed and re-opened according to grfMode. When the IStorage::OpenStorage method returns, pstgPriority is no longer valid. Use the value returned in the ppstg parameter. If the pstgPriority parameter is NULL, it is ignored.


[in]Specifies the access mode to use when opening the storage object. See the STGM enumeration values for descriptions of the possible values.


[in]Either NULL or a non-NULL value that points to a block of stream names in this storage object that are to be emptied as the object is opened. This exclusion happens independent of whether a snapshot copy happens on the open.


[in]Reserved for future use; must be zero.


[out]Points to the location where the IStorage interface pointer is returned; only valid if the operation is successful. This parameter is set to NULL if an error occurs.

Return Values


The storage object was opened successfully.


Insufficient permissions to open storage object.


The storage object with the specified name does not exist.


The storage object was not opened due to a lack of memory.


The value specified for the grfMode flag is not a valid STGM enumeration value.


The specified combination of grfMode flags is not supported.


Invalid value for pwcsName.


The pointer specified for the storage object was invalid.


One of the parameters was invalid.


The object has been invalidated by a revert operation above it in the transaction tree.


The storage object was not created because there are too many open files.


The existing stream with the specified name was replaced with a new storage object containing a single stream called CONTENTS. The new storage object will be added.


Root storage objects can be opened with STGM_DELETEONRELEASE, in which case the object is destroyed when it receives its final release. This is useful for creating temporary storage objects.

Note to Callers

The OLE-provided compound file implementation of the IStorage::OpenStorage method does not support the following behaviors:

  • The STGM_PRIORITY flag is not supported for non-root storages.

  • Opening the same storage object more than once from the same parent storage is not supported. The STGM_SHARE_EXCLUSIVE flag must be specified.

Other implementations of IStorage might support these features.

See Also


Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database