CallbackFilter

Instant control over file and folder operations in Windows and .NET applications

OnOpenFileN event/delegate/notification

Filter:

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

CallbackFilter     See also    

Overview

This notification callback is called after the OS has processed file or directory opening request.

Declaration

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

[C++ (Lib)]
    typedef void (*CbFltOpenFileEventN)(CallbackFilter* Sender, LPWSTR FileName, DWORD DesiredAccess, DWORD FileAttributes, WORD ShareMode, DWORD Options, CreateDisposition, LONG Status);

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

[C++ (.NET)]
    public delegate void CbFltOpenFileEventN(CallbackFilter^ Sender, String^ FileName, UInt32 DesiredAccess, UInt32 FileAttributes, UInt16 ShareMode, UInt32 Options, UInt16 CreateDisposition, Int32 Status);

[C#]
    delegate void CbFltOpenFileEventN(CallbackFilter Sender, string FileName, UInt32 DesiredAccess, UInt32 FileAttributes, UInt16 ShareMode, UInt32 Options, UInt16 CreateDisposition, Int32 Status);

[VB.NET]
    Delegate Sub CbFltOpenFileEventN(ByVal Sender As CallbackFilter, 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)

Parameters

  • Sender - reference to the class that called the delegate/event handler
  • FileName - contains the name of the file to open
  • DesiredAccess - desired mode of access to the opened file (dwDesiredAccess parameter of CreateFile() Windows API function)
  • FileAttributes - the attributes to be set for the opened 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)
  • Status - status code of the completed operation

Description

This notification callback is called after the OS has processed the request to open a file or directory with given name and attributes. When the callback is called, the file is already created and opened.

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, what was opened (file or directory), check FileAttributes as follows (C++ / C# notation): Directory = FileAttributes & FILE_ATTRIBUTE_DIRECTORY == FILE_ATTRIBUTE_DIRECTORY;

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.

See also

OwnProcessFiltered     OnCreateFileN     OnOpenFileC    

Back to top