Compartir a través de


BindMoniker

A version of this page is also available for

Windows Embedded CE 6.0 R3

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, *ppvResult contains the requested interface pointer.

    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::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::BindToObject 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 calls to CreateBindCtx and BindToObject.

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.

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

Reference

CreateBindCtx
IMoniker::BindToObject
COM Functions