@@ -24,17 +24,18 @@ namespace winrt::impl
2424 return error_class_not_available;
2525 }
2626
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
2930 {
3031 if (winrt_activation_handler)
3132 {
32- return winrt_activation_handler (*(void **)(&name), guid_of<Interface>() , result);
33+ return winrt_activation_handler (*(void **)(&name), guid , result);
3334 }
3435
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 ;
3637 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);
3839
3940 if (hr == impl::error_not_initialized)
4041 {
@@ -47,7 +48,7 @@ namespace winrt::impl
4748
4849 void * cookie;
4950 usage (&cookie);
50- hr = handler (*(void **)(&name), guid_of<Interface>() , result);
51+ hr = handler (*(void **)(&name), guid , result);
5152 }
5253
5354 if (hr == 0 )
@@ -87,13 +88,13 @@ namespace winrt::impl
8788 continue ;
8889 }
8990
90- if constexpr (std::is_same_v< Interface, Windows::Foundation::IActivationFactory> )
91+ if constexpr (isSameInterfaceAsIActivationFactory )
9192 {
9293 *result = library_factory.detach ();
9394 library.detach ();
9495 return 0 ;
9596 }
96- else if (0 == library_factory.as (guid_of<Interface>() , result))
97+ else if (0 == library_factory.as (guid , result))
9798 {
9899 library.detach ();
99100 return 0 ;
@@ -103,6 +104,12 @@ namespace winrt::impl
103104 WINRT_IMPL_SetErrorInfo (0 , error_info.get ());
104105 return hr;
105106 }
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+ }
106113}
107114
108115WINRT_EXPORT namespace winrt
0 commit comments