|
CreateBindCtx
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
| );
|
|
Parameters
reserved
Indicates reserved for future use; must be zero.
ppbc
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
S_OK
Indicates the bind context was allocated and initialized successfully.
E_OUTOFMEMORY
Indicates insufficient memory.
Comments
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
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 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
grfMode = STGM_READWRITE
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
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|