@@ -24,17 +24,18 @@ namespace winrt::impl
24
24
return error_class_not_available;
25
25
}
26
26
27
- template <typename Interface>
28
- hresult get_runtime_activation_factory (param::hstring const & name, void ** result) noexcept
27
+
28
+ template <bool isSameInterfaceAsIActivationFactory>
29
+ __declspec (noinline) hresult get_runtime_activation_factory_impl (param::hstring const & name, winrt::guid const & guid, void ** result) noexcept
29
30
{
30
31
if (winrt_activation_handler)
31
32
{
32
- return winrt_activation_handler (*(void **)(&name), guid_of<Interface>() , result);
33
+ return winrt_activation_handler (*(void **)(&name), guid , result);
33
34
}
34
35
35
- static int32_t (__stdcall * handler)(void * classId, guid const & iid, void ** factory) noexcept ;
36
+ static int32_t (__stdcall * handler)(void * classId, winrt:: guid const & iid, void ** factory) noexcept ;
36
37
impl::load_runtime_function (" RoGetActivationFactory" , handler, fallback_RoGetActivationFactory);
37
- hresult hr = handler (*(void **)(&name), guid_of<Interface>() , result);
38
+ hresult hr = handler (*(void **)(&name), guid , result);
38
39
39
40
if (hr == impl::error_not_initialized)
40
41
{
@@ -47,7 +48,7 @@ namespace winrt::impl
47
48
48
49
void * cookie;
49
50
usage (&cookie);
50
- hr = handler (*(void **)(&name), guid_of<Interface>() , result);
51
+ hr = handler (*(void **)(&name), guid , result);
51
52
}
52
53
53
54
if (hr == 0 )
@@ -87,13 +88,13 @@ namespace winrt::impl
87
88
continue ;
88
89
}
89
90
90
- if constexpr (std::is_same_v< Interface, Windows::Foundation::IActivationFactory> )
91
+ if constexpr (isSameInterfaceAsIActivationFactory )
91
92
{
92
93
*result = library_factory.detach ();
93
94
library.detach ();
94
95
return 0 ;
95
96
}
96
- else if (0 == library_factory.as (guid_of<Interface>() , result))
97
+ else if (0 == library_factory.as (guid , result))
97
98
{
98
99
library.detach ();
99
100
return 0 ;
@@ -103,6 +104,12 @@ namespace winrt::impl
103
104
WINRT_IMPL_SetErrorInfo (0 , error_info.get ());
104
105
return hr;
105
106
}
107
+
108
+ template <typename Interface>
109
+ hresult get_runtime_activation_factory (param::hstring const & name, void ** result) noexcept
110
+ {
111
+ return get_runtime_activation_factory_impl<std::is_same_v<Interface, Windows::Foundation::IActivationFactory>>(name, guid_of<Interface>(), result);
112
+ }
106
113
}
107
114
108
115
WINRT_EXPORT namespace winrt
0 commit comments