Discuss this help topic in CBFS Forum

CallbackFileSystem.GetOriginatorProcessId method


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

CallbackFileSystem     See also    


Returns the PID (process ID) of the process that initiated the operation


    function GetOriginatorProcessId( var ProcessId : LongWord) : boolean;

[C++ (Lib)]
    bool GetOriginatorProcessId( unsigned long * ProcessId);

[C++ (VCL)]
    bool __fastcall GetOriginatorProcessId( unsigned long& ProcessId);

[C++ (.NET)]
    bool GetOriginatorProcessId( unsigned long & ProcessId);

    bool GetOriginatorProcessId( ref UInt32 ProcessId);

    Function GetOriginatorProcessId( ByRef ProcessId As UInt32) As Boolean

    boolean getOriginatorProcessId( longRef processId);


  • ProcessId - On return this parameter contains the PID of the process.

Return values

TRUE / true if the function succeeded or FALSE / false if the function failed.


Use GetOriginatorProcessId to get the process ID (PID) of the process that originated the operation.

Note that the PID is guaranteed to be unique only during lifetime of the process. When the process is terminated, its PID can (in theory) be used by other process. In fact this never happens, but such possibility is documented by Microsoft.

Do not call this method from handlers for OnReadFile, OnWriteFile and other callbacks that work with opened files, as that callbacks can be initiated by the system components (cache manager, memory manager etc.). Instead do the following:

  1. Call GetOriginatorProcessId from OnCreateFile or OnOpenFile event handlers / callbacks;
  2. Store obtained information somewhere and store the reference to this information in the UserContext;
  3. When you need to check the originator information in some file-related callback, access the stored information via UserContext

Call from...

This method may be called only from callback / event handlers.

See also

GetOriginatorProcessName     GetOriginatorToken    

Discuss this help topic in CBFS Forum