BindMoniker  12PFRU9

Locates an object by means of its moniker, activates the object if it is inactive, and retrieves a pointer to the specified interface on that object.

HRESULT BindMoniker(

    LPMONIKER pmk,

//Pointer to the object s moniker 

    DWORD grfOpt,

//Reserved

    REFIID iidResult,

//Interface identifier

    LPVOID FAR *ppvResult

//Indirect pointer to requested interface

   );

 

 

Parameters

pmk

[in] Pointer to the object s moniker.

grfOpt

[in] Reserved for future use; must be zero.

iidResult

[in] Interface identifier to be used to communicate with the object.

ppvResult

[out] Indirect pointer to the requested interface. If an error occurs, ppvResult is NULL. If the call is successful, the caller is responsible for releasing the pointer with a call to the object s IUnknown::ReleaseDUW01A.

 

Return Values

S_OK

The object was located and activated, if necessary, and that a pointer to the requested interface was returned.

MK_E_NOOBJECT

The object that the moniker object identified could not be found.

 

This function can also return any of the error values returned by the IMoniker::BindToObject486P_PV method.

Remarks

BindMoniker is a helper function supplied as a convenient way for a client that has the moniker of an object to obtain a pointer to one of its interfaces. The BindMoniker function packages the following calls:

CreateBindCtx(0, &pbc);

pmk->BindToObject(pbc, NULL, riid, ppvObj);

 

CreateBindCtx creates a bind context object that supports the system implementation of IBindContext. The pmk parameter is actually a pointer to the IMoniker implementation on a moniker object. This implementation s BindToObject method supplies the pointer to the requested interface pointer.

If you have several monikers to bind in quick succession, and if you know that those monikers will activate the same object, it may be more efficient to call the IMoniker::BindToObject486P_PV method directly, which allows you to use the same bind context object for all the monikers. See the IBindCtx1JJ0LSF interface for more information.

Container applications that allow their documents to contain linked objects are a special client that generally does not make direct calls to IMoniker methods. Instead, the client manipulates the linked objects through the IOleLink2CFAZVF interface. The default handler implements this interface and calls the appropriate IMoniker methods as needed.

See Also

CreateBindCtx, IMoniker::BindToObject