Επεξεργασία

Κοινή χρήση μέσω


PathMakeUniqueName function (shlobj_core.h)

Creates a unique path name from a template.

Syntax

BOOL PathMakeUniqueName(
  [out]          PWSTR  pszUniqueName,
                 UINT   cchMax,
  [in]           PCWSTR pszTemplate,
  [in, optional] PCWSTR pszLongPlate,
  [in, optional] PCWSTR pszDir
);

Parameters

[out] pszUniqueName

Type: PWSTR

A buffer that receives a null-terminated Unicode string that contains the unique path name. It should be at least MAX_PATH characters in length.

cchMax

Type: UINT

The number of characters in the buffer pointed to by pszUniqueName.

[in] pszTemplate

Type: PCWSTR

A null-terminated Unicode string that contains a template that is used to construct the unique name. This template is used for drives that require file names with the 8.3 format. This string should be no more than MAX_PATH characters in length, including the terminating null character.

[in, optional] pszLongPlate

Type: PCWSTR

A null-terminated Unicode string that contains a template that is used to construct the unique name. This template is used for drives that support long file names. This string should be no more than MAX_PATH characters in length, including the terminating null character.

[in, optional] pszDir

Type: PCWSTR

A null-terminated string that contains the directory in which the new file resides. This string should be no more than MAX_PATH characters in length, including the terminating null character.

Return value

Type: BOOL

Returns TRUE if successful; otherwise, FALSE.

Remarks

This function generates a new unique file name based on the templates specified by pszTemplate, for drives that require the 8.3 format, and pszLongPlate for drives that support long file names. For example, if you specify "My New Filename" for pszLongPlate, PathMakeUniqueName returns names such as "My New Filename (1)", "My New Filename (2)", and so on.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlobj_core.h (include Shlobj.h)
Library Shell32.lib
DLL Shell32.dll (version 5.0 or later)