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.
| 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.
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:
- Create a bind context by calling the CreateBindCtx function.
- Call the IMoniker::BindToObject method on the moniker, retrieving an interface pointer.
- Release the bind context.
- Use the interface pointer.
- Release the interface pointer.
Here's a code fragment that illustrates these steps:
// pMnk is an IMoniker * that points to a previously-acquired moniker
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
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
grfMode = STGM_READWRITE
dwTickCountDeadline = 0.
You can call the IBindCtx::SetBindOptions
method to modify these values, if you want values other from the defaults.
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages