winrt::attach_abi function (C++/WinRT)

A helper function that attaches a C++/WinRT object to a handle, or to a raw pointer that owns a reference to its target. In the case of pointers, an additional reference is not added. If needed, you can use this function to coalesce references. For more info, and code examples, see Interop between C++/WinRT and the ABI.

Syntax

void attach_abi(winrt::com_ptr<T>& object, T* value) noexcept;
void attach_abi(winrt::hstring& object, HSTRING value) noexcept;
void attach_abi(winrt::Windows::Foundation::IUnknown& object, void* value) noexcept;

Parameters

object A C++/WinRT object to operate on.

value A handle, or a raw pointer that owns a reference to its target.

Requirements

Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)

Namespace: winrt

Header %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)

See also