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
//Address of output variable that receives the
// interface pointer requested in iidResult
);
This function can also return any of the error values returned by the IMoniker::BindToObject method.
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::BindToObject method directly, which allows you to use the same bind context object for all the monikers. See the IBindCtx 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 IOleLink interface. The default handler implements this interface and calls the appropriate IMoniker methods as needed.
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in objbase.h.
Import Library: Included as a resource in ole32.dll.
CreateBindCtx, IMoniker::BindToObject