Control over registry operations in Windows and .NET applications

OnSetAllocationSizeC event/delegate/callback


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

CallbackRegistry     See also    


This callback is called when the OS or the application needs to set the allocation size of the file.


    property OnOnSetAllocationSizeC : TCbFltSetAllocationSizeEventC;
    TCbFltSetAllocationSizeEventC = procedure(Sender : TObject; FileName: TCBString; var AllocationSize: Int64; var UserContext: pointer; var ProcessRequest: boolean) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*CbFltSetAllocationSizeEventC)(CallbackRegistry* Sender, LPWSTR FileName, __int64* AllocationSize, PVOID* UserContext, LPBOOL RequestAccepted);

[C++ (VCL)]
    typedef void __fastcall (__closure *TCbFltSetAllocationSizeEventC)(System::TObject* Sender, TCBString FileName, __int64 &AllocationSize, void* &UserContext, bool &ProcessRequest);

[C++ (.NET)]
    public delegate void CbFltSetAllocationSizeEventC(CallbackRegistry^ Sender, String^ FileName, Int64% AllocationSize, IntPtr% UserContext, bool% ProcessRequest);

    delegate void CbFltSetAllocationSizeEventC(CallbackRegistry Sender, string FileName, ref long AllocationSize, ref IntPtr UserContext, ref bool ProcessRequest);

    Delegate Sub CbFltSetAllocationSizeEventC(ByVal Sender As CallbackRegistry, ByVal FileName As String, ByRef AllocationSize As Long, ByRef UserContext As IntPtr, ByRef ProcessRequest As Boolean)


  • Sender - reference to the class that called the delegate/event handler
  • FileName - name of the file
  • AllocationSize - the size of the space, allocated for the file. This size in most cases will be larger than the actual file size.
  • UserContext - the placeholder for the application-defined data
  • ProcessRequest (RequestAccepted) - specifies, whether the request must be passed further to the underlying filters and the file system


This callback is called when the OS or the application needs to set the allocation size of the file.
Read more about contexts.

AllocationSize is usually larger (and much larger) than the size of the file data. This happens because some file operations first reserve space for the file, then start writing actual data to this file. The application should track such situations and avoid re-allocating file space where possible to improve speed.

Error handling

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

See also


Back to top