Function Reference


Retrieves the file system's 8-byte file reference number for a file

#include <WinAPIFiles.au3>
_WinAPI_GetFileID ( $hFile )


$hFile A handle to the file or directory whose reference number is to be retrieved.

Return Value

Success: The 8-byte file reference number for the file.
Failure: 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.


The file reference number is assigned by the file system and is file-system-specific.
(Note that this is not the same as the 16-byte "file object ID" that was added to NTFS.)

The file reference numbers, also called file IDs, are guaranteed to be unique only within a static file system.
They are not guaranteed to be unique over time, because file systems are free to reuse them.
Nor are they guaranteed to remain constant.
For example, the FAT file system generates the file reference number for a file from the byte offset of the file's directory entry record (DIRENT) on the disk.
Defragmentation can change this byte offset.
Thus a FAT file reference number can change over time.

See Also

Search ZwQueryInformationFile in MSDN Library.


#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Local $hFile = _WinAPI_CreateFile(@ScriptFullPath, 2, 0, 6)

ConsoleWrite('Handle: ' & $hFile & @CRLF)
ConsoleWrite('ID:     ' & _WinAPI_GetFileID($hFile) & @CRLF)