UtilStringCopyWithAlloc function

The UtilStringCopyWithAlloc function allocates and copies a source string.

Syntax

HRESULT UtilStringCopyWithAlloc(
  _Out_ LPWSTR  *Buffer,
  _In_  UINT    BufferMax,
  _In_  LPCWSTR Source
);

Parameters

Buffer [out]

Type: LPWSTR*

The location where the pointer to the allocated memory is stored. When no longer needed, it must be released with CoTaskMemFree. This buffer is always null-terminated.

BufferMax [in]

Type: UINT

The maximum number of characters to read from Source.

Source [in]

Type: LPCWSTR

The string to be copied.

Return value

Type: HRESULT

Possible return values include, but are not limited to, the following.

Return code Description
S_OK
The operation succeeded.
E_INVALIDARG
One or more parameters has not been provided correctly.

Requirements

Requirement Value
Minimum supported client
Windows 8 [desktop apps only]
Minimum supported server
Windows Server 2012 [desktop apps only]
Header
Ndattributils.h

See also

CoTaskMemFree

UtilAssembleStringsWithAlloc

UtilLoadStringWithAlloc