OnProcessTermination event/delegate/callback


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

CBFSProcess     See also    


This callback is called during process termination.


    property OnProcessTermination : TProcessTerminationEvent;
    TProcessTerminationEvent = procedure( Sender : TObject; ProcessId: LongWord; ProcessName: TCBString ) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*ProcessTerminationEvent)( CBFSProcess* Sender, unsigned long ProcessId, PCWSTR ProcessName );

[C++ (VCL)]
    typedef void __fastcall (__closure *TProcessTerminationEvent)( System::TObject* Sender, unsigned long ProcessId, TCBString ProcessName );

[C++ (.NET)]
    public delegate void ProcessTerminationEvent( CBFSProcess^ Sender, UInt32 ProcessId, UInt32 CreatingThreadId, String^ ProcessName );

    delegate void ProcessTerminationEvent( CBFSProcess Sender, UInt32 ProcessId, String ProcessName );

    Delegate Sub ProcessTerminationEvent( ByVal Sender As CBFSProcess, ByVal ProcessId As UInt32, ByVal ProcessName As String )


  • Sender - reference to the class that called the delegate/event handler
  • ProcessId - ID of the process being closed.
  • ProcessName - The name of the process identified by ProcessId parameter. The value is the same as GetProcessName(ProcessId) call would return.


The callback is called at the time of process termination, just before the last thread to exit the process is destroyed. This is just a notification about termination and can not be used to cancel the termination. To prevent process termination use OnProcessHandleOperation event.

Error handling

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

See also

OnProcessHandleOperation     OnProcessCreation