Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
PathCchRenameExtension

PathCchRenameExtension function

Replaces a file name's extension at the end of a path string with a new extension. If the path string does not end with an extension, the new extension is added.

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

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

Syntax


HRESULT PathCchRenameExtension(
  _Inout_ PWSTR  pszPath,
  _In_    size_t cchPath,
  _In_    PCWSTR pszExt
);

Parameters

pszPath [in, out]

A pointer to the path string. When this function returns successfully, this value points to the same string, but with the renamed or added extension.

cchPath [in]

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

pszExt [in]

A pointer to the new extension string. The leading '.' character is optional. In the case of an empty string (""), any existing extension in the path string is removed.

Return value

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

Requirements

Minimum supported client

Windows 8 [desktop apps only]

Minimum supported server

Windows Server 2012 [desktop apps only]

Header

Pathcch.h

Library

Pathcch.lib

 

 

Community Additions

ADD
Show:
© 2015 Microsoft