GetFileTitleW function

Retrieves the title of a file.

Also see GetFileTitleA.

Syntax

BOOL GetFileTitleW(
      _In_    LPCWSTR lpszFile,
      _Out_   LPWSTR  lpszTitle,
      _In_    UINT    cchTitle
);

Parameters

Return value

Returns a non-zero value if successful or zero otherwise.
If the function succeeds, the return value is the length, in characters, of the string copied to lpszTitle, not including the terminating null character.

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

Remarks

This function extracts the file title from a file path.

This function is a wrapper for the SHGetFileTitle function.

The title is the portion of the file path following the last backslash character or the entire path if no backslash character is present.

The function handles both ANSI and Unicode strings. The GetFileTitle function is an alias for GetFileTitleW.

If the file name contains no extension, the file title will not contain an extension.

The buffer pointed to by lpszTitle must be large enough to hold the file title plus the null terminator.

Consider using SHGetFileInfo with the SHGFI_DISPLAYNAME flag to get the display name of a file, which may include the extension.

Requirements

Header comdlg32.h (include windows.h)
Library Comdlg32.lib
DLL Comdlg32.dll

See also

Common Dialog Box Library

Functions

GetFileTitleA

SHGetFileInfo

SHGetFileTitle