IMoniker::BindToStorage

HRESULT IMoniker::BindToStorage(pbc, pmkToLeft, iid, ppvObj)

Return access to the persistent storage of the receiver using the given interface, rather than access to the object itself, which is what IMoniker::BindToObject returns. Consider, for example, a moniker which refers to spreadsheet embedded in a word processing document, such as:


[c:\foo\bar.doc]File Moniker +(composition operation) [summaryTable]Item Moniker

Calling IMoniker::BindToObject on this composite will enable us to talk to the spreadsheet; calling IMoniker::BindToStorage will let us to talk to the IStorage instance in which it resides.

IMoniker::BindToStorage will most often be called during the right-to-left recursive process of IMoniker::BindToObject invoked on a Generic Composite Moniker. Sometimes it is the case that monikers in the tail of the composite don't require access to the object on their left; they merely require access to its persistent storage. In effect, these monikers can be bound to without also binding to the objects of the monikers to their left, potentially a much more efficient operation.

Some objects do not have an independently identifiable piece of storage. These sorts of objects are really only a object-veneer on the internal state of their container. Examples include named cell ranges inside a Microsoft Excel worksheet, and fragments of a Microsoft Windows Word document delimited by bookmarks. Attempting to call IMoniker::BindToStorage on a moniker which indicates one of these kinds of objects will fail with the error MK_E_NOSTORAGE.

Use of the bind context in IMoniker::BindToStorage is the same as in IMoniker::BindToObject.

Argument

Type

Description

pbc

IBindCtx*

The binding context for this binding operation.

iid

REFIID

The interface by which we want to bind to this storage. Common interfaces passed here include IStorage, IStream, and ILockBytes.

ppvObj

void**

On successful return, a pointer to the instantiated storage is placed here, unless BINDFLAGS_JUSTTESTEXISTENCE was specified in the binding options, in which case NULL may be returned instead.

return value

HRESULT

S_OK, MK_E_NOSTORAGE, MK_E_EXCEEDEDDEADLINE, MK_E_CONNECTMANUALLY, E_NOINTERFACE, MK_E_INTERMEDIATEINTERFACENOTSUPPORTED, STG_E_ACCESSDENIED