Instant control over file and folder operations in Windows and .NET applications

OnPostWriteFileC event/delegate/callback


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

CallbackFilter     See also    


This callback is called when the OS needs to write the data from the open file or volume.


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

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

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

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

    delegate void CbFltPostWriteFileEventC(CallbackFilter^ Sender, string FileName, long Position, IntPtr Buffer, Int32 BytesToWrite, bool Cached, Int32 Status, ref IntPtr UserContext);

    Delegate Sub CbFltPostWriteFileEventC(ByVal Sender As CallbackFilter, ByVal FileName As String, ByVal Position As Long, ByVal Buffer As IntPtr, ByVal BytesToWrite As Int32, ByVal Cached As Boolean, ByVal Status As Int32, ByRef 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 write the file data to
  • Buffer - the buffer to put the write data
  • BytesToWrite - the number of bytes to write 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 event is fired when the OS writes the data to the open file or volume, after the request has been passed to the underlying file system. To have a copy of the data that was written, access the data in the provided buffer.

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

Read more about contexts.

See also

OnWriteFileC     OnWriteFileN    

Back to top