winrt::get_class_name function (C++/WinRT)
A helper function that retrieves a string containing the fully-qualified type name of the Windows Runtime class represented by an object of a given projected type. This is the same value returned from a call to IInspectable::GetRuntimeClassName.
This is a free function that retrieves the runtime class name of any arbitrary IInspectable. For the automatically-generated member function that's available only on implementation types, see GetRuntimeClassName. For an explanation of the implementation type and projected type concepts, see Consume APIs with C++/WinRT and Author APIs with C++/WinRT.
Syntax
inline winrt::hstring get_class_name(winrt::Windows::Foundation::IInspectable const& object);
Parameters
object
An instance of the projected type for a Windows Runtime class (any runtime class; whether it's a Windows type, or a second- or third-party type).
Return value
A winrt::hstring containing the fully-qualified type name of the Windows Runtime class represented by object
. Note that the type of the Windows Runtime class is returned, not that of the projected type. In the example below, the C++/WinRT projected type is winrt::Windows::Foundation::Uri, but the value returned from winrt::get_class_name is "Windows.Foundation.Uri", which is the type name of the runtime class.
Example
winrt::Windows::Foundation::Uri contosoUri{ L"https://www.contoso.com" };
winrt::hstring name = winrt::get_class_name(contosoUri);
assert(name == L"Windows.Foundation.Uri");
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
- winrt namespace
- Consume APIs with C++/WinRT
- Author APIs with C++/WinRT
- IInspectable::GetRuntimeClassName, the raw WinRT function that this helper wraps