EldoS
 Table of Contents >  OnCreateFileC event/delegate/callback
Navigation
Web site
Support
Table Of Contents

OnCreateFileC event/delegate/callback

Filter:

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

CallbackFilter     See also    

Overview

This callback is called when the OS handles file or directory creation request.

Declaration

[Pascal]
    property OnCreateFileC : TCbFltCreateFileEventC;
    TCbFltCreateFileEventC = procedure(Sender : TObject; FileName: TCBString; var DesiredAccess: DWORD; var FileAttributes: WORD; var ShareMode: WORD; var Options: DWORD; var CreateDisposition: WORD; var ProcessRequest: boolean) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*CbFltCreateFileEventC)(CallbackFilter* Sender, LPWSTR FileName, DWORD* DesiredAccess, WORD* FileAttributes, WORD* ShareMode, DWORD* Options, WORD* CreateDisposition, LPBOOL RequestAccepted);

[C++ (VCL)]
    typedef void __fastcall (__closure *TCbFltCreateFileEventC)(System::TObject* Sender, TCBString FileName, unsigned long &DesiredAccess, unsigned short &FileAttributes, unsigned short &ShareMode, unsigned long &Options, unsigned short &CreateDisposition, bool &ProcessRequest);
    #ifdef UNICODE
    typedef UnicodeString TCBString;
    #else
    typedef WideString TCBString;
    #endif

[C++ (.NET)]
    public delegate void CbFltCreateFileEventC(CallbackFilter^ Sender, String^ FileName, UInt32% DesiredAccess, UInt16% FileAttributes, UInt16% ShareMode, UInt32% Options, UInt32% CreateDisposition, bool% ProcessRequest);

[C#]
    delegate void CbFltCreateFileEventC(CallbackFilter Sender, string FileName, ref UInt32 DesiredAccess, ref UInt16 FileAttributes, ref UInt16 ShareMode, ref UInt32 Options, ref UInt16 CreateDisposition, ref bool ProcessRequest);

[VB.NET]
    Delegate Sub CbFltCreateFileEventC(ByVal Sender As CallbackFilter, ByVal FileName As String, ByRef DesiredAccess As UInt32, ByRef FileAttributes As UInt16, ByRef ShareMode As UInt16, ByRef Options As UInt32, ByRef CreateDisposition As UInt16, ByRef ProcessRequest As Boolean)

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • FileName - contains the name of the file to create
  • DesiredAccess - desired mode of access to the created file (dwDesiredAccess parameter of CreateFile() Windows API function)
  • FileAttributes - the attributes to be set for the newly created file
  • ShareMode - desired share mode (dwShareMode parameter of CreateFile() Windows API function)
  • Options - requested FILE_FLAG_xxx options (dwFlagsAndAttributes parameter of CreateFile() Windows API function)
  • CreateDisposition - requested creation disposition (dwCreationDisposition parameter of CreateFile() Windows API function)
  • ProcessRequest (RequestAccepted) - specifies, whether the request must be passed further to the underlying filters and the file system

Description

This callback is called when the OS wants to create a file or directory with given name and attributes.

DesiredAccess, FileAttributes, ShareMode, Options and CreateDisposition are passed as they were specified in the call to CreateFile() Windows API function. For more details check MSDN library shipped with your development tool and also available online.

To check, whether it's file or directory that should be opened, check FileAttributes as follows (C++ / C# notation): Directory = FileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY;

This callback is called before the file has been opened. It can happen that the file will not be opened by the underlying file system. If you want to be notified when the file is already opened, use OnPostCreateFileC event.

If your application initiates file create/open operation AND filters such requests at the same time (eg. for debugging or testing purposes), you need to set OwnProcessFiltered property to true.

Read more about when excatly On*CreateFile* and On*OpenFile* callbacks are called.

Error handling

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

See also

OwnProcessFiltered     OnCreateFileN     OnPostCreateFileC

Contact Us | Terms of Use | Trademarks | Privacy Statement
Copyright (c) 1998-2011, EldoS Corporation