Control process start and stop operations in Windows and .NET applications

OnCloseKeyHandle event/delegate/callback


Pascal    C++ (Lib)    C++ (VCL)    C++ (.NET)    C#    VB.NET   

CallbackProcess     See also    


This callback is called when an application-provided key handle should be closed.


    property OnCloseKeyHandle : TCBProcCloseKeyHandleEvent;
    TCBProcCloseKeyHandleEvent = procedure( Sender : TObject; UserContext: pointer; KeyHandle: THandle; KeyHandleContext: pointer; Error: LongWord ) of object;

[C++ (Lib)]
    typedef void (*CBProcCloseKeyHandleEvent)( CallbackProcess* Sender, LPVOID UserContext, HANDLE KeyHandle, PVOID KeyHandleContext, DWORD Error );

[C++ (VCL)]
    typedef void __fastcall (__closure *TCBProcCloseKeyHandleEvent)( System::TObject* Sender, void * UserContext, unsigned KeyHandle, void * KeyHandleContext, unsigned Error );

[C++ (.NET)]
    public delegate void CBProcCloseKeyHandleEvent( CallbackProcess^ Sender, Object^ UserContext, SafeHandle^ KeyHandle, Object^ KeyHandleContext, UInt32 Error );

    delegate void CBProcCloseKeyHandleEvent( CallbackProcess Sender, Object UserContext, SafeHandle KeyHandle, Object KeyHandleContext, UInt32 Error );

    Delegate Sub CBProcCloseKeyHandleEvent( ByVal Sender As CallbackProcess, ByVal UserContext As Object, ByVal KeyHandle As SafeHandle, ByVal KeyHandleContext As Object, ByVal Error As UInt32 )


  • Sender - reference to the class that called the delegate/event handler
  • UserContext - the placeholder for the application-defined data
  • KeyHandle - handle of the key to be closed
  • KeyHandleContext - the placeholder for the application-defined data set in On*CreateKey or On*OpenKey together with the key handle
  • Error - contains the error code if the error happened during the use of the application-provided key


The callback/event is used to ask the application to close an application-provided handle passed from the CBProcPreCreateKeyEvent or CBProcPreOpenKeyEvent callbacks.
Read more about contexts.

Error handling

See Error handling topic for detailed information about how to report errors, which occur in the event handlers, back to CallbackProcess.

See also

OnPreCreateKey     OnPreOpenKey    

Back to top