SHStrDup function
Makes a copy of a string in newly allocated memory.
Syntax
HRESULT SHStrDup( _In_ LPCTSTR pszSource, _Out_ LPTSTR *ppwsz );
Parameters
- pszSource [in]
-
Type: LPCTSTR
A pointer to the null-terminated string to be copied.
- ppwsz [out]
-
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.
Requirements
|
Minimum supported client |
Windows 2000 Professional, Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
SHStrDupW (Unicode) and SHStrDupA (ANSI) |
See also