winrt::handle_type 结构模板 (C++/WinRT)
winrt::handle 和 winrt::file_handle结构等的模板。
注意
你可以定义自己的句柄特征, (查看,例如, handle_traits 或 file_handle_traits在) , \cppwinrt\winrt\base.h
并将其与 winrt::handle_type 一起使用 typename T
。 将其中一个示例复制到 base.h
自己的源代码文件中,并提供自己的句柄类型和实现。 MSDN 杂志文章中提供了使用 C++ Windows的更多详细信息。
语法
template <typename T>
struct handle_type
模板参数
typename T
一种特征类型,指定 (句柄、文件句柄或其他类型) 表示的句柄类型。
要求
支持的最低 SDK:Windows SDK 版本 10.0.17134.0 (Windows 10版本 1803)
命名空间: winrt
标头: %WindowsSdkDir%IncludeWindowsTargetPlatformVersion<>\cppwinrt\winrt\base.h (默认包含)
成员类型别名
别名名称 | 类型 |
---|---|
handle_type::type | typename T::type 的同义词,其中 T 是typename T 模板参数。 |
构造函数
构造函数 | 说明 |
---|---|
handle_type::handle_type 构造函数 | 使用输入数据的副本或移动(可选)初始化 handle_type 结构的新实例。 |
成员函数
函数 | 说明 |
---|---|
handle_type::attach 函数 | 附加到句柄值,并获取其所有权。 |
handle_type::close 函数 | 关闭基础句柄。 |
handle_type::d etach 函数 | 从基础句柄分离。 |
handle_type::get 函数 | 如果需要将基础句柄传递给函数,则返回基础句柄。 |
handle_type::p ut 函数 | 返回基础句柄的地址;此函数有助于通过指向句柄的指针调用以输出参数的形式返回引用的方法。 |
成员运算符
操作员 | 说明 |
---|---|
handle_type::operator bool | 检查 handle_type 对象当前是否表示有效的句柄。 |
handle_type::operator= (赋值运算符) | 将值分配给 handle_type 对象。 |
免费函数
函数 | 说明 |
---|---|
swap 函数 | 交换两 个handle_type 参数的内容,以便它们包含彼此的句柄。 |
handle_type::handle_type 构造函数
使用输入数据的副本或移动(可选)初始化 handle_type 结构的新实例。
语法
handle_type() noexcept;
explicit handle_type(handle_type::type value) noexcept;
handle_type(handle_type&& other) noexcept;
parameters
value
初始化 handle_type 对象的值。
other
另一个初始化handle_type对象的handle_type。
handle_type::attach 函数
附加到句柄值,并获取其所有权。
语法
void attach(handle_type::type value) noexcept;
parameters
value
要附加到的句柄值。
handle_type::close 函数
关闭基础句柄。
语法
void close() noexcept;
handle_type::d etach 函数
从基础句柄分离。
语法
handle_type::type detach() noexcept;
返回值
以前由 handle_type 对象表示的基础句柄。
handle_type::get 函数
如果需要将其传递给函数,则返回基础句柄。
语法
handle_type::type get() const noexcept;
返回值
由handle_type对象表示的基础句柄。
handle_type::p ut 函数
返回基础句柄的地址;此函数有助于通过指向句柄的指针调用以输出参数的形式返回引用的方法。
语法
handle_type::type* put() noexcept;
返回值
由handle_type对象表示的基础句柄的地址。
handle_type::operator bool
检查 handle_type 对象当前是否表示有效的句柄。
语法
explicit operator bool() const noexcept;
返回值
true
if the handle_type object currently represents a valid handle, otherwise false
.
handle_type::operator= (赋值运算符)
将值分配给 handle_type 对象。
语法
winrt::handle_type& operator=(winrt::handle_type&& other) noexcept;
parameters
other
要分配给handle_type对象的handle_type值。
返回值
对 handle_type 对象的引用。
swap 函数
交换两 个handle_type 参数的内容,以便它们包含彼此的句柄。
语法
void swap(winrt::handle_type& left, winrt::handle_type& right) noexcept;
parameters
left
right
一个handle_type值,其句柄与另一个参数的相互交换。
请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈