Retrieves an interface pointer to the storage that contains the object identified by the moniker. Unlike the IMoniker::BindToObject method, this method does not activate the object identified by the moniker.
HRESULT BindToStorage(
IBindCtx *pbc, //Pointer to bind context to be used
IMoniker *pmkToLeft, //Pointer to moniker to the left of this one
//in the composite
REFIID riid, //Reference to the identifier of the storage
//interface requested
void **ppvObj //Address of output variable that receives
//the interface pointer requested in riid
);
The method supports the standard return value E_OUTOFMEMORY, as well as the following:
There is an important difference between the IMoniker::BindToObject and IMoniker::BindToStorage methods. If, for example, you have a moniker that identifies a spreadsheet object, calling IMoniker::BindToObject provides access to the spreadsheet object itself, while calling IMoniker::BindToStorage provides access to the storage object in which the spreadsheet resides.
Although none of the COM moniker classes call this method in their binding operations, it might be appropriate to call it in the implementation of a new moniker class. You could call this method in an implementation of IMoniker::BindToObject that requires information from the object identified by the pmkToLeft parameter and can get it from the persistent storage of the object without activation. For example, if your monikers are used to identify objects that can be activated without activating their containers, you may find this method useful.
A client that can read the storage of the object its moniker identifies could also call this method.
Your implementation should locate the persistent storage for the object identified by the current moniker and return the desired interface pointer. Some types of monikers represent pseudo-objects, which are objects that do not have their own persistent storage. Such objects comprise some portion of the internal state of its container; as, for example, a range of cells in a spreadsheet. If your moniker class identifies this type of object, your implementation of IMoniker::BindToStorage should return the error MK_E_NOSTORAGE.
If the bind context's BIND_OPTS structure specifies the BINDFLAGS_JUSTTESTEXISTENCE flag, your implementation has the option of returning NULL in ppvObj (although it can also ignore the flag and perform the complete binding operation).
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in objidl.h.