WindowsDuplicateString 函数 (winstring.h)

创建指定字符串的副本。

Syntax

HRESULT WindowsDuplicateString(
  HSTRING string,
  HSTRING *newString
);

参数

string

类型:[in] HSTRING

要复制的字符串。

newString

类型:[out] HSTRING*

字符串的副本。

返回值

类型:HRESULT

此函数可以返回其中一个值。

返回代码 Description
S_OK
已成功复制 HSTRING。
E_INVALIDARG
newString 为 NULL。
E_OUTOFMEMORY
未能分配新的 HSTRING。

注解

使用 WindowsDuplicateString 函数复制 HSTRING。 如果 字符串 是通过调用 WindowsCreateString 函数创建的,则支持缓冲区的引用计数会递增。 如果 字符串 是通过调用 WindowsCreateStringReference 函数创建的,则 Windows 运行时将其源字符串复制到新缓冲区并启动引用计数,这意味着 newString 不是快速传递字符串。

对 WindowsDuplicateString 函数的每个调用都必须与对 WindowsDeleteString 的相应调用匹配。

要求

Requirement 价值
最低支持的客户端 Windows 8 [桌面应用 |UWP 应用]
支持的最低服务器 Windows Server 2012 [桌面应用 |UWP 应用]
目标平台 Windows操作系统
Header winstring.h
Library RuntimeObject.lib

另请参阅

WindowsCreateString

WindowsCreateStringReference

WindowsDeleteString