CreateBindCtx  R6KCRQ

Supplies a pointer to an implementation of IBindCtx (a bind context object). This object stores information about a particular moniker-binding operation. The pointer this function supplies is required as a parameter in many methods of the IMoniker18XK102 interface and in certain functions related to monikers.

WINOLEAPI CreateBindCtx(

    DWORD reserved,

//Reserved for future use

    LPBC FAR* ppbc

//Indirect pointer to the bind context

   );

 

 

Parameters

reserved

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

ppbc

[out] Indirect pointer to an IBindCtx1JJ0LSF interface on the new bind context object. When the function is successful, the caller is responsible for calling IUnknown::ReleaseDUW01A on the parameter. A NULL value indicates that an error occurred.

 

Return Values

This function supports the standard return value E_OUTOFMEMORY, as well as the following:

S_OK

The bind context was allocated and initialized successfully.

 

Remarks

CreateBindCtx is 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 CreateBindCtx function.

  2.  Call the IMoniker::BindToObject486P_PV method 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 fragment illustrates 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 IMoniker18XK102 interface besides IMoniker::BindToObject486P_PV and in the MkParseDisplayName2DJJ.25 function.

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_OPTS3_HO_Y. structure, 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_OPTS structure are initialized to the following values:

cbStruct = sizeof(BIND_OPTS)

grfFlags = 0

grfMode = STGM_READWRITE

dwTickCountDeadline = 0.

 

You can call the IBindCtx::SetBindOptions.L_W2Z method to modify these default values.

See Also

BIND_OPTS, IBindCtx, IMoniker, MkParseDisplayName