Contexts is a placeholder for application-defined data. The data, placed to Context, is not used by CBFS Registry in any way but can and should be used to pass information from one callback to another.
Why are Contexts useful?
Contexts can be used to store information about the key or key handle and this information can be re-used later to speed-up subsequent operations. The only place where the name of the key is passed is OnPreCreateKey/OnPreOpenKey callback/event. You can store this name in the context and access it in all subsequent callbacks, related to the created/opened key handle. This includes OnPostCreateKey/OnPostOpenKey, key operation callbacks/events and On*CloseKey callbacks/events.
In value operation events (eg. OnPreDeleteValueKey/OnPostDeleteValueKey) you can store the value name passed in OnPreDeleteValueKey callback/event handler to the context and pick this name from the context in OnPostDeleteValueKey callback/event handler.
For key operations contexts live from key open to key close calls.
Contexts are stored with other information, related to an opened key.
Contexts are local to the process in which they were created. They can't be passed to other processes.
Use of Contexts in VCL and C++/Lib API is quite straightforward - you just put pointers to Context.
In .NET the context is of Object type, so you can store a reference to any class in the context.
To store numbers or other types, that are not objects, use "boxing" (.NET concept, when a value type is "packed" into an object).