Control over registry operations in Windows and .NET applications

OnCanFileBeDeletedC event/delegate/callback


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

CallbackRegistry     See also    


This callback is called when the OS needs to query possibility to delete the file or directory.


    property OnCanFileBeDeletedC : TCbFltCanFileBeDeletedEventC;
    TCbFltCanFileBeDeletedEventC = procedure(Sender : TObject; FileName: TCBString; var DeleteFile: Boolean; var UserContext: pointer; var ProcessRequest: boolean) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

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

[C++ (VCL)]
    typedef void __fastcall (__closure *TCbFltCanFileBeDeletedEventC)(System::TObject* Sender, TCBString FileName, bool &DeleteFile, void * UserContext, bool &ProcessRequest);
    #ifdef UNICODE
    typedef UnicodeString TCBString;
    typedef WideString TCBString;

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

    delegate void CbFltCanFileBeDeletedEventC(CallbackRegistry Sender, string FileName, ref bool DeleteFile, ref IntPtr UserContext, ref bool ProcessRequest);

    Delegate Sub CbFltCanFileBeDeletedEventC(ByVal Sender As CallbackRegistry, ByVal FileName As String, ByRef DeleteFile, ByRef UserContext As IntPtr, ByRef ProcessRequest As Boolean)


  • Sender - reference to the class that called the delegate/event handler
  • FileName - name of the file
  • DeleteFile - set this parameter to allow or prevent deletion of the file
  • 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 needs to check if the file or directory can be deleted.

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

OnPostCanFileBeDeletedC     OnCanFileBeDeletedN    

Back to top