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.
A version of this page is also available for
4/8/2010

This method opens an existing storage object with the specified name according to the specified access mode.

Syntax

HRESULT OpenStorage( 
  const WCHAR* 
pwcsName, 
  IStorage* 
pstgPriority, 
  DWORD 
grfMode, 
  SNB 
snbExclude, 
  DWORD 
reserved, 
  IStorage** 
ppstg 
);

Parameters

pwcsName

[in] Pointer to a wide character string that contains the name of the storage object to open. It is ignored if the pstgPriorityparameter is non-NULL.

pstgPriority

[in] If the pstgPriorityparameter is not NULL, it is an IStorageinterface 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 the grfModeparameter.

When the IStorage::OpenStoragemethod returns, pstgPriorityis no longer valid. Use the value supplied in the ppstgparameter.

If the pstgPriorityparameter is NULL, it is ignored.

grfMode

[in] Access mode to use when opening the storage object. See the STGMenumeration values for descriptions of the possible values.

Whatever other modes you choose, you must at least specify STGM_SHARE_EXCLUSIVE when calling this method.

snbExclude

[in] Set to NULL. A non-NULL value will return STG_E_INVALIDPARAMETER.

reserved

[in] Reserved for future use; set to zero.

ppstg

[out] When the operation is successful, pointer to the location of an IStoragepointer to the opened storage object.

This parameter is set to NULL if an error occurs.

Return Value

The following table shows the return values for this method.

Value Description

S_OK

The storage object was opened successfully.

E_PENDING

Asynchronous Storage only: Part or all of the storage's data is currently unavailable.

For more information see the IFillLockBytesinterface and Asynchronous Storage.

STG_E_ACCESSDENIED

Insufficient permissions to open storage object.

STG_E_FILENOTFOUND

The storage object with the specified name does not exist.

STG_E_INSUFFICIENTMEMORY

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

STG_E_INVALIDFLAG

The value specified for the grfModeflag is not a valid STGMenumeration value.

STG_E_INVALIDFUNCTION

The specified combination of grfModeflags is not supported.

STG_E_INVALIDNAME

Invalid value for pwcsName.

STG_E_INVALIDPOINTER

The pointer specified for the storage object was invalid.

STG_E_INVALIDPARAMETER

One of the parameters was invalid.

STG_E_REVERTED

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

STG_E_TOOMANYOPENFILES

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

STG_S_CONVERTED

The existing stream with the specified name was replaced with a new storage object that contains a single stream called CONTENTS.

In direct mode, the new storage is immediately written to disk.

In transacted mode, the new storage is written to a temporary storage in memory and later written to disk when it is committed.

Remarks

Storageobjects 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.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Requirements

Header objidl.h, objidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later
508 Resource Limit Is Reached

Resource Limit Is Reached

The website is temporarily unable to service your request as it exceeded resource limit. Please try again later.