IBindHost::MonikerBindToObject

Binds to the object named by the specified moniker.

HRESULT MonikerBindToObject(

IMoniker *pMk

// Moniker to be bound

IBindCtx *pBC

// Optional bind context

IBindStatusCallback *pBSC

// The control’s callback interface

REFIID rii

// 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::BindToObject.
ppvObj
[out] The result of the bind operation (if it is synchronous). This parameter serves the same purpose as the analogous parameter in IMoniker::BindToObject.

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::MonikerBindToObject should be the first mechanism that controls use to bind to the object addressed by a moniker (if a control container doesn’t support IBindHost, then the control should directly call IMoniker::BindToObject). This function behaves the same as IMoniker::BindToObject, except that it enables the control’s 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.