CallbackProcess

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

OnProcessCreation event/delegate/callback

Filter:

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

CallbackProcess     See also    

Overview

This callback is called during process creation.

Declaration

[Pascal]
    property OnProcessCreation : TProcessCreationEvent;
    TCBProcProcessCreationEvent = procedure( Sender : TObject; ProcessId: LongWord; ParentProcessId: LongWord; CreatingProcessId: LongWord; CreatingThreadId: LongWord; ProcessName: TCBString; ImageFileName: TCBString; FileOpenNameAvailable: boolean; CommandLine: TCBString ) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*ProcessCreationEvent)( CallbackProcess* Sender, unsigned long ProcessId, unsigned long ParentProcessId, unsigned long CreatingProcessId, unsigned long CreatingThreadId, PCWSTR ProcessName, PCWSTR ImageFileName, bool FileOpenNameAvailable, PCWSTR CommandLine );

[C++ (VCL)]
    typedef void __fastcall (__closure *TProcessCreationEvent)( System::TObject* Sender, unsigned long ProcessId, unsigned long ParentProcessId, unsigned long CreatingProcessId, unsigned long CreatingThreadId, TCBString ProcessName, TCBString ImageFileName, bool FileOpenNameAvailable, TCBString CommandLine );

[C++ (.NET)]
    public delegate void ProcessCreationEvent( CallbackProcess^ Sender, UInt32 ProcessId, UInt32 ParentProcessId, UInt32 CreatingProcessId, UInt32 CreatingThreadId, String^ ProcessName, String^ ImageFileName, bool FileOpenNameAvailable, String^ CommandLine );

[C#]
    delegate void ProcessCreationEvent( CallbackProcess Sender, UInt32 ProcessId, UInt32 ParentProcessId, UInt32 CreatingProcessId, UInt32 CreatingThreadId, String ProcessName, String ImageFileName, bool FileOpenNameAvailable, String CommandLine );

[VB.NET]
    Delegate Sub ProcessCreationEvent( ByVal Sender As CallbackProcess, ByVal ProcessId As UInt32, ByVal ParentProcessId As UInt32, ByVal CreatingProcessId As UInt32, ByVal CreatingThreadId As UInt32, ByVal ProcessName As String, ByVal ImageFileName As String, ByVal FileOpenNameAvailable As Boolean, ByVal CommandLine As String )

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • ProcessId - ID of the process being created.
  • ParentProcessId - ID of the parent process for the new process. Note that the parent process is not necessarily the same process as the process that created the new process. The new process can inherit certain properties of the parent process, such as handles or shared memory.
  • CreatingProcessId - ID of the process that created the new process.
  • CreatingThreadId - ID of the thread that created the new process.
  • ProcessName - The name of the process identified by ProcessId parameter. The value is the same as GetProcessName(ProcessId) call would return.
  • ImageFileName - The name of the executable file from which the process is created. Can be full or partial.
  • FileOpenNameAvailable - If the FileOpenNameAvailable is TRUE, ImageFileName specifies the exact file name that is used to open the executable file. If FileOpenNameAvailable is FALSE, the operating system provides only a partial name.
  • CommandLine - The command line used to start the process.

Description

The callback is called at the time of process creation after the initial thread is created, but before the thread begins running. You can cancel process creation by throwing an instance of ECBProcError exception (eg. you can use ACCESS_DENIED error code to inform the system about the reason of the error).

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

OnProcessTermination    

Back to top