PBSetDefaultComponent and PBSetDefaultContext

Components and Contexts Overview, Working With Components and Contexts

PB_COMPONENT* PBSetDefaultComponent (PB_COMPONENT* pcp, INT iOption)

PB_CONTEXT* PBSetDefaultContext (PB_CONTEXT* pcx, INT iOption)

Return value

Returns a pointer to the previous default component or context. Returns NULL on error or if no default was previously set.


pcp Pointer to the component to use as the new default for the module or thread.

pcx Pointer to the context to use as the new default for the module or thread.

iOption The level to which the default structure is applied. May be one of the following:

PB_THREAD_DEFAULT Set the structure as the default for this thread.

PB_MODULE_DEFAULTSet the structure as the default for the entire module.


For a given process, thread defaults can only be set for a maximum of 64 threads at one time regardless of whether the threads have default components, contexts, or both. If an attempt is made to specify too many thread defaults simultaneously, the last thread to attempt to set a default will have no default at the thread level and simply behave as if the operation had not been attempted. The failure will result in error notification 2011. Each time one of these functions is called with iOption equal to PB_THREAD_DEFAULT, defaults that were set and never unset for threads that have terminated are removed.

If the functions are called with pcp or pcx equal to NULL then the default is unset for the module or the calling thread, depending on the value of iOption. This is typically used to unset a thread default so that it no longer overrides the module default or to clean up the resources required for a thread default when it is no longer needed. Resources associated with thread default components or contexts that are never unset will be automatically cleaned up when the process terminates or PBUninitialize is called.

See the discussion of handle leaks in the Troubleshooting appendix for further information on resources used in keeping track of thread default components and context.