From 6dbba705b3127757dbb36f16911790d776934527 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 26 Feb 2024 12:27:02 +0100 Subject: [PATCH] Refine uninstall logic to account for legacy windows features --- osu.Desktop/Windows/WindowsAssociationManager.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 4bb8e57c9d..490faab632 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -222,12 +222,21 @@ public void UpdateDescription(RegistryKey classes, string description) programKey?.SetValue(null, description); } + /// + /// Uninstalls the file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/shell/fa-file-types#deleting-registry-information-during-uninstallation + /// public void Uninstall(RegistryKey classes) { - // importantly, we don't delete the default program entry because some other program could have taken it. + using (var extensionKey = classes.OpenSubKey(Extension, true)) + { + // clear our default association so that Explorer doesn't show the raw programId to users + // the null/(Default) entry is used for both ProdID association and as a fallback friendly name, for legacy reasons + if (extensionKey?.GetValue(null) is string s && s == programId) + extensionKey.SetValue(null, string.Empty); - using (var extensionKey = classes.OpenSubKey($@"{Extension}\OpenWithProgIds", true)) - extensionKey?.DeleteValue(programId, throwOnMissingValue: false); + using (var openWithKey = extensionKey?.CreateSubKey(@"OpenWithProgIds")) + openWithKey?.DeleteValue(programId, throwOnMissingValue: false); + } classes.DeleteSubKeyTree(programId, throwOnMissingSubKey: false); }