Control over registry operations in Windows and .NET applications

OnReadFileC event/delegate/callback


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

CallbackRegistry     See also    


This callback is called right after the OS reads the data from the open file.


    property OnReadFileC : TCbFltReadFileEventC;
    TCbFltReadFileEventC = procedure(Sender : TObject; FileName: TCBString; Position: Int64; var Buffer; BytesToRead: LongWord; Cached: Boolean; Status : DWORD; var UserContext: pointer) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*CbFltReadFileEventC)(CallbackRegistry* Sender, LPWSTR FileName, __int64 Position, PVOID Buffer, DWORD BytesToRead, BOOL Cached, LONG Status, PVOID* UserContext);

[C++ (VCL)]
    typedef void __fastcall (__closure *TCbFltReadFileEventC)(System::TObject* Sender, TCBString FileName, __int64 Position, void *Buffer, unsigned long BytesToRead, bool Cached, DWORD Status, void * UserContext);

[C++ (.NET)]
    public delegate void CbFltReadFileEventC(CallbackRegistry^ Sender, String^ FileName, Int64 Position, IntPtr Buffer, Int32 BytesToRead, bool Cached, Int32 Status, IntPtr% UserContext);

    delegate void CbFltReadFileEventC(CallbackRegistry^ Sender, string FileName, long Position, IntPtr Buffer, Int32 BytesToRead, bool Cached, Int32 Status, ref IntPtr UserContext);

    Delegate Sub CbFltReadFileEventC(ByVal Sender As CallbackRegistry, ByVal FileName As String, ByVal Position As Long, ByVal Buffer As IntPtr, ByVal BytesToRead As Int32, ByVal Cached As Boolean, ByVal Status As Int32, ByRref UserContext As IntPtr)


  • Sender - reference to the class that called the delegate/event handler
  • FileName - contains the name of the file
  • Position - the starting position to read the file data from
  • Buffer - the buffer to put the read data
  • BytesToRead - the number of bytes to read from the file. The Buffer contains not more space, than this value.
  • Cached - specified if the operation is cached
  • Status - status code of the completed operation
  • UserContext - the placeholder for the application-defined data


This callback is called when the OS needs to read the data from the open file, after the request was processed by the underlying file system. In the callback handler for this callback you can perform postprocessing of the data which have been read from the file.

If you need to modify the data which were read, write the data (no more than BytesToRead bytes) to the provided Buffer.

To report the failure and cancel reading operation you need to throw an instance of ECBFltError.

In .NET you should not try to replace the Buffer. Instead you need to copy the data to the provided buffer. You can use Array.Copy method for this.

Read more about contexts.

See also


Back to top