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

OnProcessTermination event/delegate/callback


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

CallbackProcess     See also    


This callback is called during process termination.


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

[C++ (Lib)]
    typedef void (*ProcessTerminationEvent)( CallbackProcess* 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( CallbackProcess^ Sender, UInt32 ProcessId, UInt32 CreatingThreadId, String^ ProcessName );

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

    Delegate Sub ProcessTerminationEvent( ByVal Sender As CallbackProcess, 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 CallbackProcess.

See also

OnProcessHandleOperation     OnProcessCreation    

Back to top