OnWriteFile event/delegate/callback

Filter:

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

CBFSConnect     See also    

Overview

This event is fired when the OS needs to write the data to the open file or volume.

Declaration

[Pascal]
    property OnWriteFile : TCBWriteFileEvent;
    TCBWriteFileEvent = procedure( Sender : TObject; FileInfo: TCBFileInfo; Position: Int64; var Buffer; BytesToWrite: LongWord; var BytesWritten: LongWord ) of object;

[C++ (Lib)]
    void (__stdcall *CBWriteFileEvent)(void* Sender, CBFileInfo* FileInfo, long long Position, void * Buffer, unsigned long BytesToWrite, unsigned long & BytesWritten );

[C++ (VCL)]
    typedef void (__closure *TCBWriteFileEvent)( System::TObject* Sender, TCBFileInfo* FileInfo, __int64 Position, void * Buffer, unsigned long BytesToWrite, unsigned long & BytesWritten );

[C++ (.NET)]
    public __delegate void CBWriteFileEvent( CBFSConnect^ Sender, CBFileInfo^ FileInfo, Int64 Position, Byte Buffer[], Int32 BytesToWrite, Int32% BytesWritten );

    public __delegate void CBWriteFileNativeEvent( CBFSConnect^ Sender, CBFileInfo^ FileInfo, Int64 Position, IntPtr Buffer, Int32 BytesToWrite, Int32% BytesWritten );

[C#]
    public void CBWriteFileEvent( CBFSConnect Sender, CBFileInfo FileInfo, Int64 Position, byte[] Buffer, Int32 BytesToWrite, ref Int32 BytesWritten );

    public void CBWriteFileNativeEvent( CBFSConnect Sender, CBFileInfo FileInfo, Int64 Position, IntPtr Buffer, Int32 BytesToWrite, ref Int32 BytesWritten );

[VB.NET]
    Sub CBWriteFileEvent( ByVal Sender As CBFSConnect, ByVal FileInfo As CBFileInfo, ByVal Position As Int64, ByVal Buffer As Byte(), ByVal BytesToWrite As Int32, ByRef BytesWritten As Int32 )

    Sub CBWriteFileNativeEvent( ByVal Sender As CBFSConnect, ByVal FileInfo As CBFileInfo, ByVal Position As Int64, ByVal Buffer As IntPtr, ByVal BytesToWrite As Int32, ByRef BytesWritten As Int32 )

[Java]
    void ICbFsFileEvents.onWriteFile( CBFSConnect sender, CBFileInfo fileInfo, long position, byteArrayRef buffer, int bytesToWrite, intRef bytesWritten );

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • FileInfo - contains the information about the file
  • Position - starting position to write the file data to
  • Buffer - the buffer with data to be written
  • BytesToWrite - the number of bytes to write to the file.
  • BytesWritten - the event handler must set the parameter to the number of bytes actually written to the file.

Description

This event is fired when the OS needs to write the data to the open file or volume. Note, that unless you create the virtual disk for some specific application, your callback handler should be able to write exactly BytesToWrite bytes of data. Writing less data than expected is an unexpected situation for many applications, and they will fail if you write less bytes than requested.

Read more about contexts.

Error handling

See Error handling topic for detailed information about how to report errors, which occur in the event handlers, back to CBFS Connect.

See also

MaxWriteBlockSize property     GetHandleInfo method     OnCreateFile event     OnOpenFile event     OnReadFile event