WindowsDuplicateString function

Creates a copy of the specified string.

Syntax

HRESULT WindowsDuplicateString(
  HSTRING string,
  HSTRING *newString
);

Parameters

string

Type: HSTRING

The string to be copied.

newString

Type: HSTRING*

A copy of string.

Return Value

Type: HRESULT

This function can return one of these values.

Return code Description
S_OK
The HSTRING was copied successfully.
E_INVALIDARG
newString is NULL.
E_OUTOFMEMORY
Failed to allocate the new HSTRING.

Remarks

Use the WindowsDuplicateString function to copy an HSTRING. If string was created by calling the WindowsCreateString function, the reference count of the backing buffer is incremented. If string was created by calling the WindowsCreateStringReference function, the Windows Runtime copies its source string to a new buffer and starts a reference count, which means that newString is not a fast-pass string.

Each call to the WindowsDuplicateString function must be matched with a corresponding call to WindowsDeleteString.

Requirements

   
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header winstring.h

See Also

WindowsCreateString

WindowsCreateStringReference

WindowsDeleteString