PathCchRemoveFileSpec function (pathcch.h)
Removes the last element in a path string, whether that element is a file name or a directory name. The element's leading backslash is also removed.
This function differs from PathRemoveFileSpec in that it accepts paths with "\", "\?" and "\?\UNC" prefixes.
WINPATHCCHAPI HRESULT PathCchRemoveFileSpec( [in, out] PWSTR pszPath, [in] size_t cchPath );
[in, out] pszPath
A pointer to the fully-qualified path string. When this function returns successfully, the string will have had its last element and its leading backslash removed. This function does not affect root paths such as "C:". In the case of a root path, the path string is returned unaltered. If a path string ends with a trailing backslash, only that backslash is removed.
The size of the buffer pointed to by pszPath, in characters.
This function returns S_OK if the function was successful, S_FALSE if there was nothing to remove, or an error code otherwise.
The following table shows the effect of this function on a selection of path strings.
|Original String||Returned String|
|Minimum supported client||Windows 8 [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2012 [desktop apps | UWP apps]|