WindowsReplaceString function (winstring.h)

Replaces all occurrences of a set of characters in the specified string with another set of characters to create a new string.

Syntax

HRESULT WindowsReplaceString(
  HSTRING string,
  HSTRING stringReplaced,
  HSTRING stringReplaceWith,
  HSTRING *newString
);

Parameters

string

Type: [in] HSTRING

The original string.

stringReplaced

Type: [in] HSTRING

The string to be replaced.

stringReplaceWith

Type: [in] HSTRING

The string to replace all occurrences of stringReplaced. If this parameter is NULL, all instances of stringReplaced are removed.

newString

Type: [out] HSTRING*

A string that is equivalent to the original, except that all instances of stringReplaced are replaced with stringReplaceWith.

Return value

Type: HRESULT

This function can return one of these values.

Return code Description
S_OK
The string replacement was successful.
E_INVALIDARG
newString is NULL, stringReplaced is empty, or the length of string1 plus the length of string2 is greater than MAXUINT32, which is 4,294,967,295; that is, hexadecimal 0xFFFFFFFF.
E_OUTOFMEMORY
Failed to allocate the new string.

Remarks

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

Requirements

Requirement Value
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

WindowsDeleteString