# IBindHost::MonikerBindToStorage

Binds to the persistent data of the object named by the specified moniker.

HRESULT MonikerBindToStorage(

IMoniker *pMk | // Moniker to be bound
IBindCtx *pBC | // Optional bind context
IBindStatusCallback *pBSC | // The control’s callback interface
REFIID riid | // IID of the desired storage interface
void **ppvObj | // The result of the bind operation
); |

Parameters

pMk
  [in] Pointer to the moniker to be bound.
pBC
  [in] Pointer to optional bind context to be used when binding the moniker.
pBSC
  [in] The control’s callback interface.
riid
  [in] Interface ID of desired storage interface. Serves the same purpose as the analagous parameter in IMoniker::BindToStorage.
void
  [out] The result of the bind operation (if it is synchronous). This parameter serves the same purpose as the analogous parameter in IMoniker::BindToStorage.

Return Values

S_OK
  The bind operation completed synchronously and successfully. The result of the bind operation is available in ppbObj.
MK_S_ASYNCHRONOUS
  The bind operation will complete asynchronously. Behavior matches that of IMoniker::BindToStorage.
E_OUTOFMEMORY
  There is insufficient memory to create the moniker.
E_UNEXPECTED
  An unknown error occurred.

Remarks

IBindHost::MonikerBindToStorage should be the first mechanism that controls use when trying to bind to the data addressed by a moniker (if a control container doesn’t support IBindHost, then the control should directly call IMoniker::BindToStorage). This function behaves exactly the same as IMoniker::BindToStorage, except that it enables the control container (the implementer of IBindHost) to set bind options and priority, while delegating all results and callbacks to the control.

A control can use pBC to pass additional bind options, such as a format enumerator (see IEnumFormatETC).

A control receives asynchronous callbacks pertaining to the bind operation by passing its container a pointer to the control’s IBindStatusCallback interface. The control must provide this interface separately, not registered on the pBC parameter.