SHLocalStrDupW function (shlwapi.h)

Makes a copy of a string in newly allocated memory.

Syntax

HRESULT SHLocalStrDupW(
                  PCWSTR psz,
  [out, optional] PWSTR  *ppsz
);

Parameters

psz

Type: PCTSTR

A pointer to a null-terminated, Unicode string to be copied.

[out, optional] ppsz

Type: PTSTR*

The address of a pointer to an allocated string that, when this function returns successfully, receives the result. SHLocalStrDup allocates memory for this string with LocalAlloc. You should free the string with LocalFree when it is no longer needed.

Return value

Type: HRESULT

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

Remarks

Note

The shlwapi.h header defines SHLocalStrDup as an alias that 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 is 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 Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header shlwapi.h