From 4639546472e0a60f84a0e4d36473cef8210c5378 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 13 Oct 2026 11:12:28 +0300 Subject: [PATCH] fix(windows): fall back to Settings when the default-apps dialog fails Windows 10/11 retired IApplicationAssociationRegistrationUI's advanced dialog; it fails with 0x80070490 and the user was left with only an error. Open Settings > Default apps on the app's registered page instead. Refs #725 Co-Authored-By: Claude Opus 5.5 --- src/io/file_association.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/io/file_association.rs b/src/io/file_association.rs index 50b34e1cb..e3170292e 100644 --- a/src/io/file_association.rs +++ b/src/io/file_association.rs @@ -230,10 +230,26 @@ mod windows_impl { if owns_com { CoUninitialize(); } - result + // Windows 10/11 retired the advanced-association dialog (it fails + // with 0x80070490, #725); its Settings page takes over. + result.or_else(|error| open_default_apps_settings().ok_or(error)) } } + /// Open Settings → Default apps on this app's page (Windows 11; Windows + /// 10 shows the general page). + fn open_default_apps_settings() -> Option { + let uri = format!( + "ms-settings:defaultapps?registeredAppUser={}", + APP_REGISTRY_NAME.replace(' ', "%20") + ); + std::process::Command::new("explorer.exe").arg(uri).spawn().ok()?; + Some( + "Opened Settings → Default apps — choose Open CAD Studio for .dwg / .dxf there." + .to_string(), + ) + } + use windows_sys::Win32::System::Registry::{ RegCloseKey, RegCreateKeyExW, RegDeleteTreeW, RegSetValueExW, HKEY, HKEY_CURRENT_USER, KEY_WRITE, REG_OPTION_NON_VOLATILE, REG_SZ,