PathCchFindExtension function (pathcch.h)

Searches a path to find its file name extension, such as ".exe" or ".ini". This function does not search for a specific extension; it searches for the presence of any extension.

This function differs from PathFindExtension in that it accepts paths with "\", "\?" and "\?\UNC" prefixes.

Note  This function should be used in place of PathFindExtension to prevent the possibility of a buffer overrun.

Syntax

WINPATHCCHAPI HRESULT PathCchFindExtension(
  [in]  PCWSTR pszPath,
  [in]  size_t cchPath,
  [out] PCWSTR *ppszExt
);

Parameters

[in] pszPath

A pointer to the path to search.

[in] cchPath

The size of the buffer pointed to by pszPath in characters, including the null terminator.

[out] ppszExt

The address of a pointer that, when this function returns successfully, points to the "." character that precedes the extension within pszPath. If no extension is found, it points to the string's terminating null character.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header pathcch.h
Library Pathcch.lib