IStorage::OpenStorage method (objidl.h)

The OpenStorage method opens an existing storage object with the specified name in the specified access mode.


HRESULT OpenStorage(
  const OLECHAR *pwcsName,
  IStorage      *pstgPriority,
  DWORD         grfMode,
  SNB           snbExclude,
  DWORD         reserved,
  IStorage      **ppstg



A pointer to a wide character null-terminated Unicode string that contains the name of the storage object to open. The 000 through 01f characters, serving as the first character of the stream/storage name, are reserved for use by OLE. This is a compound file restriction, not a structured storage restriction. It is ignored if pstgPriority is non-NULL.


Must be NULL. A non-NULL value will return STG_E_INVALIDPARAMETER.


Specifies the access mode to use when opening the storage object. For descriptions of the possible values, see STGM Constants. Other modes you choose must at least specify STGM_SHARE_EXCLUSIVE when calling this method.


Must be NULL. A non-NULL value will return STG_E_INVALIDPARAMETER.


Reserved for future use; must be zero.


When successful, pointer to the location of an IStorage pointer to the opened storage object. This parameter is set to NULL if an error occurs.

Return value

This method can return one of these values.


If the pstgPriority parameter is NULL, it is ignored. If the pstgPriority parameter is not NULL, it is an IStorage 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 reopened according to grfMode. When the IStorage::OpenStorage method returns, pstgPriority is no longer valid. Use the value supplied in the ppstg parameter.

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.


Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header objidl.h
Library Uuid.lib
DLL Ole32.dll

See also

IStorage - Compound File Implementation