OnPostOpenFileC event/delegate/callback

Filter:

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

CBFSFilter     See also    

Overview

This callback is called after the file/directory has been opened.

Declaration

[Pascal]
    property OnPostOpenFileC : TCBFSFltPostOpenFileEventC;
    TCBFSFltPostOpenFileEventC = procedure(Sender : TObject; FileName: TCBString; DesiredAccess: DWORD; FileAttributes: DWORD; ShareMode: WORD; Options: DWORD; CreateDisposition: WORD; Status : DWORD; var FileContext: pointer; var HandleContext: pointer) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    typedef void (*CBFSFltPostOpenFileEventC)(CBFSFilter* Sender, LPWSTR FileName, DWORD DesiredAccess, DWORD FileAttributes, WORD ShareMode, DWORD Options, WORD CreateDisposition, LONG Status, PVOID* FileContext, PVOID* HandleContext);

[C++ (VCL)]
    typedef void __fastcall (__closure *TCBFSFltPostOpenFileEventC)(System::TObject* Sender, TCBString FileName, unsigned long DesiredAccess, unsigned long FileAttributes, unsigned short ShareMode, unsigned long Options, unsigned short CreateDisposition, DWORD Status, void* *FileContext, void* *HandleContext);

[C++ (.NET)]
    public delegate void CBFSFltPostOpenFileEventC(CBFSFilter^ Sender, String^ FileName, UInt32 DesiredAccess, UInt32 FileAttributes, UInt16 ShareMode, UInt32 Options, UInt16 CreateDisposition, Int32 Status, IntPtr% FileContext, IntPtr% HandleContext);

[C#]
    delegate void CBFSFltPostOpenFileEventC(CBFSFilter Sender, string FileName, UInt32 DesiredAccess, UInt32 FileAttributes, UInt16 ShareMode, UInt32 Options, UInt16 CreateDisposition, Int32 Status, ref IntPtr FileContext, ref IntPtr HandleContext);

[VB.NET]
    Delegate Sub CBFSFltPostOpenFileEventC(ByVal Sender As CBFSFilter, ByVal FileName As String, ByVal DesiredAccess As UInt32, ByVal FileAttributes As UInt32, ByVal ShareMode As UInt16, ByVal Options As UInt32, ByVal CreateDisposition As UInt16, ByVal Status As Int32, ByRef FileContext As IntPtr, ByRef HandleContext as IntPtr)

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • FileName - contains the name of the opened file
  • DesiredAccess - requested mode of access to the opened file (dwDesiredAccess parameter of CreateFile() Windows API function)
  • FileAttributes - contains the attributes of the opened file
  • ShareMode - requested 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)
  • Status - status code of the completed operation
  • FileContext - the placeholder for the application-defined data, common to all concurrent file operations on the file
  • HandleContext - the placeholder for the application-defined data, local to each opened file handle

Description

This callback is called after the OS has opened a file or directory with given name and attributes.
To check, what has been opened (file or directory), check FileAttributes as follows (C++ / C# notation): Directory = FileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY;

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.

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.

The application can use FileContext and HandleContext to store the reference to some information that identifies the file or directory (such as a file/directory handle or a database record ID or a reference to the stream class etc). The values, set in the event handler, are later passed to all operations, related to this file (with the exception that HandleContext is not available in file read- or write-related callbacks) together with the file/directory name and attributes. Read more about contexts.

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

See also

OwnProcessFiltered     OnOpenFileC