diff --git a/crates/libs/core/src/imp/com_bindings.rs b/crates/libs/core/src/imp/com_bindings.rs index b832b95ffb..a196a54a38 100644 --- a/crates/libs/core/src/imp/com_bindings.rs +++ b/crates/libs/core/src/imp/com_bindings.rs @@ -240,5 +240,6 @@ impl IWeakReferenceSource_Vtbl { } impl windows_core::RuntimeName for IWeakReferenceSource {} pub const JSCRIPT_E_CANTEXECUTE: windows_core::HRESULT = windows_core::HRESULT(0x89020001_u32 as _); +pub const REGDB_E_CLASSNOTREG: windows_core::HRESULT = windows_core::HRESULT(0x80040154_u32 as _); pub const RPC_E_DISCONNECTED: windows_core::HRESULT = windows_core::HRESULT(0x80010108_u32 as _); pub const TYPE_E_TYPEMISMATCH: windows_core::HRESULT = windows_core::HRESULT(0x80028CA0_u32 as _); diff --git a/crates/libs/core/src/imp/factory_cache.rs b/crates/libs/core/src/imp/factory_cache.rs index fd7e5fc287..f6c1caf762 100644 --- a/crates/libs/core/src/imp/factory_cache.rs +++ b/crates/libs/core/src/imp/factory_cache.rs @@ -106,14 +106,18 @@ pub fn factory() -> crate::Result { // can ultimately return this error information if all else fails. let original: crate::Error = code.into(); - // Now attempt to find the factory's implementation heuristically. - if let Some(i) = search_path(C::NAME, |library| unsafe { - get_activation_factory(library, &name) - }) { - i.cast() - } else { - Err(original) + // Reg-free activation should only be attempted if the class is not registered. + // It should not be attempted if the class is registered but fails to activate. + if code == REGDB_E_CLASSNOTREG { + // Now attempt to find the factory's implementation heuristically. + if let Some(i) = search_path(C::NAME, |library| unsafe { + get_activation_factory(library, &name) + }) { + return i.cast(); + } } + + Err(original) } // Remove the suffix until a match is found appending `.dll\0` at the end diff --git a/crates/tools/bindings/src/core_com.txt b/crates/tools/bindings/src/core_com.txt index f821225e7b..cf24ebdc2c 100644 --- a/crates/tools/bindings/src/core_com.txt +++ b/crates/tools/bindings/src/core_com.txt @@ -6,6 +6,7 @@ --filter Windows.Win32.Foundation.CO_E_NOTINITIALIZED + Windows.Win32.Foundation.REGDB_E_CLASSNOTREG Windows.Win32.Foundation.E_BOUNDS Windows.Win32.Foundation.E_INVALIDARG Windows.Win32.Foundation.E_NOINTERFACE