Microsoft Windows CE 3.0  

CreateBindCtx

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.

This function supplies a pointer to an implementation of IBindCtx, an object that stores information about a particular moniker-binding operation.

WINOLEAPI CreateBindCtx (
DWORD
reserved, 
LPBC FAR *
ppbc
);

Parameters

reserved
[in] Reserved for future use; set to zero.
ppbc
[out] Address of IBindCtx* pointer variable that receives the interface pointer to the new bind context object. When the function is successful, the caller is responsible for calling IUnknown::Releaseon the bind context. A NULL value for the bind context indicates that an error occurred.

Return Values

S_OK indicates that the bind context was allocated and initialized successfully. The standard return value E_OUTOFMEMORY is also supported.

Remarks

CreateBindCtxis most commonly used in the process of binding a moniker (locating and getting a pointer to an interface by identifying it through a moniker), as in the following steps:

  1. Get a pointer to a bind context by calling the CreateBindCtxfunction.
  2. Call the IMoniker::BindToObjectmethod on the moniker, retrieving an interface pointer to the object to which the moniker refers.
  3. Release the bind context.
  4. Use the interface pointer.
  5. Release the interface pointer.

    The following code example shows these steps.

    // pMnk is an IMoniker * that points to a
    previously acquired moniker IFoo *pFoo; IBindCtx *pbc;
    CreateBindCtx( 0, &pbc ); pMnk->BindToObject( pbc, NULL,
    IID_IFoo, &pFoo ); pbc->Release(); // pFoo now points to the
    object; safe to use pFoo pFoo->Release();

    Bind contexts are also used in other methods of the IMonikerinterface besides IMoniker::BindToObject.

    A bind context retains references to the objects that are bound during the binding operation, causing the bound objects to remain active (keeping the object's server running) until the bind context is released. Reusing a bind context when subsequent operations bind to the same object can improve performance. You should, however, release the bind context as soon as possible, because you could be keeping the objects activated unnecessarily.

    A bind context contains a BIND_OPTSstructure, which contains parameters that apply to all steps in a binding operation. When you create a bind context using CreateBindCtx, the fields of the BIND_OPTSstructure are initialized to the following values:

    cbStruct = sizeof(BIND_OPTS) grfFlags = 0 grfMode
    = STGM_READWRITE dwTickCountDeadline = 0.

    You can call the IBindCtx::SetBindOptionsmethod to modify these default values.

    Requirements

    Runs On Versions Defined in Include Link to
    Windows CE OS 2.10 and later Objbase.h    
    Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

    See Also

    IMoniker, IMoniker::BindToObject, IUnknown::Release, BIND_OPTS