GetFinalPathNameByHandleW

Retrieves the final path for the specified file.

version(Windows)
extern (Windows) nothrow @nogc
uint
GetFinalPathNameByHandleW
(
HANDLE hFile
,,,
uint dwFlags
)

Parameters

hFile HANDLE

A handle to a file or directory.

lpszFilePath LPWSTR

A pointer to a buffer that receives the path of hFile.

cchFilePath uint

The size of lpszFilePath, in TCHARs. This value does not include a NULL termination character.

dwFlags uint

The type of result to return. This parameter can be one of the following values.

FILE_NAME_NORMALIZED - Return the normalized drive name. This is the default. FILE_NAME_OPENED - Return the opened file name (not normalized).

This parameter can also include one of the following values.

VOLUME_NAME_DOS - Return the path with the drive letter. This is the default. VOLUME_NAME_GUID - Return the path with a volume GUID path instead of the drive name. VOLUME_NAME_NONE - Return the path with no drive information. VOLUME_NAME_NT - Return the path with the volume device path.

Return Value

Type: uint

If the function succeeds, the return value is the length of the string received by lpszFilePath, in TCHARs. This value does not include the size of the terminating null character.

Windows Server 2008 and Windows Vista: For the ANSI version of this function, GetFinalPathNameByHandleA, the return value includes the size of the terminating null character.

If the function fails because lpszFilePath is too small to hold the string plus the terminating null character, the return value is the required buffer size, in TCHARs. This value includes the size of the terminating null character.

If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError.

ERROR_PATH_NOT_FOUND - Can be returned if you are searching for a drive letter and one does not exist. For example, the handle was opened on a drive that is not currently mounted, or if you create a volume and do not assign it a drive letter. If a volume has no drive letter, you can use the volume GUID path to identify it.

This return value can also be returned if you are searching for a volume GUID path on a network share. Volume GUID paths are not created for network shares.

ERROR_NOT_ENOUGH_MEMORY - Insufficient memory to complete the operation.

ERROR_INVALID_PARAMETER - Invalid flags were specified for dwFlags.

Meta