Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function 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.

Syntax

HRESULT BindMoniker(
  LPMONIKER 
pmk,
  DWORD 
grfOpt,
  REFIID 
iidResult,
  LPVOID FAR* 
ppvResult
);

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] Address of pointer variable that receives the interface pointer requested in iidResult.

Upon successful return, * ppvResultcontains the requested interface pointer.

If an error occurs, * ppvResultis NULL.

If the call is successful, the caller is responsible for releasing the pointer with a call to the object's IUnknown::Release.

Return Value

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::BindToObjectmethod.

Remarks

BindMonikeris 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 BindMonikerfunction packages calls to CreateBindCtxand BindToObject.

CreateBindCtxcreates a bind context object that supports the system implementation of IBindContext. The pmkparameter is actually a pointer to the IMonikerimplementation on a moniker object. This implementation's BindToObjectmethod 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::BindToObjectmethod directly, which allows you to use the same bind context object for all the monikers. See the IBindCtxinterface 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 IMonikermethods. Instead, the client manipulates the linked objects through the IOleLinkinterface.

The default handler implements this interface and calls the appropriate IMonikermethods as needed.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header objbase.h
Library ole32.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also