Discuss this help topic in CBFS Forum

OnGetFileNameByFileId event/delegate/callback


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



The event is fired when translation of the File ID to file path must be done.


    property OnGetFileNameByFileId : TCbFsGetFileNameByFileIdEvent;
    TCbFsGetFileNameByFileIdEvent = procedure( Sender : TObject; FileId: Int64; var FilePath: TCBString; var FilePathLength: WORD ) of object;
    type TCBString = {$ifdef UNICODE}UnicodeString{$else}WideString{$endif};

[C++ (Lib)]
    void (__stdcall *CbFsGetFileNameByFileIdEvent)(void* Sender, __int64* FileId, void* FilePath, DWORD * FilePathLength );

[C++ (VCL)]
    typedef void (__closure *CbFsGetFileNameByFileIdEvent)( System::TObject* Sender, long long FileId, TCBString & FilePath, unsigned long & FilePathLength );

[C++ (.NET)]
    public __delegate void CbFsGetFileNameByFileIdEvent( CallbackFileSystem^ Sender, Int64 FileId, String^% FilePath, UInt16% FilePathLength );

    public void CbFsGetFileNameByFileIdEvent( CallbackFileSystem Sender, Int64 FileId, ref String FilePath, ref UInt16 FilePathLength );

    Sub CbFsGetFileNameByFileIdEvent( ByVal Sender As CallbackFileSystem, ByVal FileId As Int64, ByRef FilePath As String, ByRef FilePathLength As UInt16 )

    void ICbFsFileEvents.onGetFileNameByFileId( CallbackFileSystem sender, long fileId, stringRef filePath, longRef filePathLength );


  • Sender - reference to the class that called the delegate/event handler
  • FileId - Id of the file, whose path should be retrieved
  • FilePath - the placeholder for the file path. Size of the buffer is equal to MaxFilePathLength characters
  • FilePathLength - Length (in characters without trailing NULL) of the file path, placed to FilePath parameter


The following callback routine is called to get a file name (with full path to it) based on a file id. This callback is called only when someone tries to open a file by its FileId (when FILE_OPEN_BY_FILE_ID is specified during ZwCreateFile call). After it this name is used to open the file (the OnOpenFile callback with this name is called). FileId == 0x7FFFFFFFFFFFFFFF denotes the root directory (i.e. "\").

The event is optional i.e. if you don't support file IDs, you don't need to handle the event. However, if you use Hard Links feature, you must handle this event.

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.

Discuss this help topic in CBFS Forum