Επεξεργασία

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


PathCompactPathExW function (shlwapi.h)

Truncates a path to fit within a certain number of characters by replacing path components with ellipses.

Syntax

BOOL PathCompactPathExW(
  [out] LPWSTR  pszOut,
  [in]  LPCWSTR pszSrc,
  [in]  UINT    cchMax,
  [in]  DWORD   dwFlags
);

Parameters

[out] pszOut

Type: LPTSTR

The address of the string that has been altered.

[in] pszSrc

Type: LPCTSTR

A pointer to a null-terminated string of length MAX_PATH that contains the path to be altered.

[in] cchMax

Type: UINT

The maximum number of characters to be contained in the new string, including the terminating null character. For example, if cchMax = 8, the resulting string can contain a maximum of 7 characters plus the terminating null character.

[in] dwFlags

Type: DWORD

Return value

Type: BOOL

Returns TRUE if successful, or FALSE otherwise.

Remarks

The '/' separator will be used instead of '\' if the original string used it. If pszSrc points to a file name that is too long, instead of a path, the file name will be truncated to cchMax characters, including the ellipsis and the terminating NULL character. For example, if the input file name is "My Filename" and cchMax is 10, PathCompactPathEx will return "My Fil...".

Note

The shlwapi.h header defines PathCompactPathEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header shlwapi.h
Library Shlwapi.lib
DLL Shlwapi.dll (version 4.71 or later)