Platform SDK: Files and I/O

GetFullPathName

The GetFullPathName function retrieves the full path and file name of a specified file.

DWORD GetFullPathName(
  LPCTSTR lpFileName,  // file name
  DWORD nBufferLength, // size of path buffer
  LPTSTR lpBuffer,     // path buffer
  LPTSTR *lpFilePart   // address of file name in path
);

Parameters

lpFileName
[in] Pointer to a null-terminated string that specifies a valid file name. This string can use either short (the 8.3 form) or long file names.
nBufferLength
[in] Specifies the size, in TCHARs, of the buffer for the drive and path.
lpBuffer
[out] Pointer to a buffer that receives the null-terminated string for the name of the drive and path.
lpFilePart
[out] Pointer to a buffer that receives the address (in lpBuffer) of the final file name component in the path.

Return Values

If the GetFullPathName function succeeds, the return value is the length, in TCHARs, of the string copied to lpBuffer, not including the terminating null character.

If the lpBuffer buffer is too small, the return value is the size of the buffer, in TCHARs, required to hold the path.

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

Remarks

GetFullPathName merges the name of the current drive and directory with the specified file name to determine the full path and file name of the specified file. It also calculates the address of the file name portion of the full path and file name. This function does not verify that the resulting path and file name are valid or that they refer to an existing file on the associated volume.

GetFullPathName does no conversion of the specified file name, lpFileName. If the specified file name exists, you can use GetLongPathName and GetShortPathName to convert to long and short path names, respectively.

MAPI: For more information, see Syntax and Limitations for Win32 Functions Useful in MAPI Development.

Requirements

  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

File I/O Overview, File I/O Functions, GetLongPathName, GetShortPathName, GetTempPath, SearchPath