forked from 1b-agent/opencadstudio-upstream
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
4762987fef
commit
4639546472
1 file changed
+17
-1
@@ -230,10 +230,26 @@ mod windows_impl {
|
|||||||
if owns_com {
|
if owns_com {
|
||||||
CoUninitialize();
|
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<String> {
|
||||||
|
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::{
|
use windows_sys::Win32::System::Registry::{
|
||||||
RegCloseKey, RegCreateKeyExW, RegDeleteTreeW, RegSetValueExW, HKEY, HKEY_CURRENT_USER,
|
RegCloseKey, RegCreateKeyExW, RegDeleteTreeW, RegSetValueExW, HKEY, HKEY_CURRENT_USER,
|
||||||
KEY_WRITE, REG_OPTION_NON_VOLATILE, REG_SZ,
|
KEY_WRITE, REG_OPTION_NON_VOLATILE, REG_SZ,
|
||||||
|
|||||||
Reference in new issue
Block a user