SHStrDupW function (shlwapi.h)
Makes a copy of a string in newly allocated memory.
Syntax
LWSTDAPI SHStrDupW(
[in] LPCWSTR psz,
[out] LPWSTR *ppwsz
);
Parameters
[in] psz
Type: LPCTSTR
A pointer to the null-terminated string to be copied.
[out] ppwsz
Type: LPTSTR*
A pointer to an allocated Unicode string that contains the result. SHStrDup allocates memory for this string with CoTaskMemAlloc. You should free the string with CoTaskMemFree when it is no longer needed.
In the case of failure, this value is NULL.
Return value
Type: HRESULT
Returns S_OK if successful, or a COM error value otherwise.
Remarks
This function will take either Unicode or ANSI strings as input, but the copied string is always Unicode.
This function uses CoTaskMemAlloc to allocate memory for the copied string. You must free this memory with CoTaskMemFree when it is no longer needed.
Note
The shlwapi.h header defines SHStrDup 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 5.0 or later) |