OnOpenFile event/delegate/callback
Filter:
Pascal C++ (Lib) C++ (VCL) C++ (.NET) C# VB.NETOverview
This event is fired when the OS handles file or directory open event.
Declaration
[Pascal]
property OnOpenFile : TCbFsOpenFileEvent;
TCbFsOpenFileEvent = procedure(
Sender : TObject;
FileName: WideString;
DesiredAccess: LongWord;
ShareMode: LongWord;
var FileHandleContext: Pointer
) of object;
[C++ (Lib)]
void (__stdcall *CbFsOpenFileEvent)(void* Sender,
wchar_t* FileName,
unsigned long DesiredAccess,
unsigned long ShareMode,
void ** FileHandleContext
);
[C++ (VCL)]
typedef void (__closure *TCbFsOpenFileEvent)(
System::TObject* Sender,
WideSrting FileName,
unsigned long DesiredAccess,
unsigned long ShareMode,
void ** FileHandleContext
);
[C++ (.NET)]
public __delegate void CbFsOpenFileEvent(
CallbackFileSystem^ Sender,
String^ FileName,
UInt32 DesiredAccess,
UInt32 ShareMode,
IntPtr% FileHandleContext
);
[C#]
public void CbFsOpenFileEvent(
CallbackFileSystem^ Sender,
string FileName,
UInt32 DesiredAccess,
UInt32 ShareMode,
ref IntPtr FileHandleContext
);
[VB.NET]
Sub CbFsOpenFileEvent(
ByVal Sender As CallbackFileSystem,
ByVal FileName As String,
ByVal DesiredAccess As UInt32,
ByVal ShareMode As UInt32,
ByRef FileHandleContext As IntPtr
)
Parameters
- Sender - reference to the class that called the delegate/event handler
- FileName - the name of the file to open
- DesiredAccess - desired mode of access to the created file
- ShareMode -
- FileHandleContext - the placeholder for the application-defined data
Description
This event is fired when the OS wants to open an existing file or directory with given name and attributes. The directory can be opened, for example, in order to change it's attributes or to enumerate it's contents.
If the file name contains semicolon (":"), this means that the request is made to open a named stream in a file. The part before the semicolon is the name of the file itself and the name after the semicolon is the name of the named stream. If you don't want to deal with named streams, don't implement the handler for OnEnumerateNamedStreams event. In this case CBFS API will tell the OS that the named streams are not supported by the file system.
The application can use FileHandleContext to store the reference to some information, identifying the file or directory (such as file/directory handle or database record ID or reference to the stream class etc).
The value, set in the event handler, is later passed to all operations, related to this file, together with file/directory name and attributes.
Read more about contexts.
Security checks
Your code is responsible for checking access rights of the process, which accesses the file system object. See Security checks topic for detailed information about how to check security.
Error handling
See Error handling topic for detailed information about how to report errors, which occur in the event handlers, back to Callback File System.
