This topic has not yet been rated - Rate this topic

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 containing the result. SHStrDup allocates memory for this string with CoTaskMemAlloc. You should free the string with CoTaskMemFree when it is no longer needed.

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

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 5.0 or later)

Unicode and ANSI names

SHStrDupW (Unicode) and SHStrDupA (ANSI)

See also

StrDup

 

 

Send comments about this topic to Microsoft

Build date: 11/28/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.