Creates a bind context. A bind context is an object that stores information about a particular moniker-binding operation. A bind context is required as a parameter in many methods of the IMoniker interface and in certain functions related to monikers.

STDAPI CreateBindCtx(

DWORD reserved,
//Reserved for future use
LPBC FAR* ppbc
//Receives the pointer to the bind context



Indicates reserved for future use; must be zero.


Receives an IBindCtx interface pointer to the new bind context. The returned pointer is NULL if an error occurs; if non-NULL, the caller is responsible for calling IUnknown::Release on the parameter.

Return Values


Indicates the bind context was allocated and initialized successfully.


Indicates insufficient memory.


The most common use of CreateBindCtx is in binding a moniker (getting a pointer to an interface by ideintifying it through a moniker). This X typically takes the following steps:

  1. Create a bind context by calling the CreateBindCtx function.

  2. Call the IMoniker::BindToObject method on the moniker, retrieving an interface pointer.

  3. Release the bind context.

  4. Use the interface pointer.

  5. Release the interface pointer.

Here's a code fragment that 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 );


// pFoo now points to the object; safe to use pFoo


Bind contexts are also used in other methods of the IMoniker interface besides IMoniker::BindToObject and in the MkParseDisplayName function.

A bind context retains references to the objects that are bound during the binding operation. This causes the bound objects to remain active until the bind context is released. This can improve performance in subsequent binding operations if they are trying to bind to the same objects. However, this potential performance enhancement should be balanced against the costs of keeping the objects activated unnecessarily (i.e., keeping the object's server running).

In general, you can benefit from reusing a bind context for a few sequential bind operations if those operations are likely to require the same objects, but you should release the bind context rather than holding onto it for a long period. If you don't release the bind context, objects registered with the bind context will remain active unnecessarily.

A bind context contains a BIND_OPTS structure, which contains parameters that apply to all steps in a binding operations. 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


dwTickCountDeadline = 0.

You can call the IBindCtx::SetBindOptions method to modify these values, if you want values other from the defaults.

See Also

BIND_OPTS, IBindCtx, IMoniker, MkParseDisplayName

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database