From cdcf5bddda5c15c518a810af6b68b06ab214ee52 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 3 Feb 2024 17:56:14 +0100 Subject: [PATCH] Uninstall associations when uninstalling from squirrel --- osu.Desktop/Program.cs | 2 ++ .../Visual/Updater/TestSceneWindowsAssociationManager.cs | 2 +- osu.Game/Updater/WindowsAssociationManager.cs | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index a7453dc0e0..c9ce5ebf1b 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -12,6 +12,7 @@ using osu.Framework.Platform; using osu.Game; using osu.Game.IPC; using osu.Game.Tournament; +using osu.Game.Updater; using SDL2; using Squirrel; @@ -180,6 +181,7 @@ namespace osu.Desktop { tools.RemoveShortcutForThisExe(); tools.RemoveUninstallerRegistryEntry(); + WindowsAssociationManager.UninstallAssociations(@"osu"); }, onEveryRun: (_, _, _) => { // While setting the `ProcessAppUserModelId` fixes duplicate icons/shortcuts on the taskbar, it currently diff --git a/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs b/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs index 72256860fd..f3eb468334 100644 --- a/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs +++ b/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs @@ -100,7 +100,7 @@ namespace osu.Game.Tests.Visual.Updater [Test] public void TestNotifyShell() { - AddStep("notify shell of changes", () => associationManager.NotifyShellUpdate()); + AddStep("notify shell of changes", WindowsAssociationManager.NotifyShellUpdate); } } } diff --git a/osu.Game/Updater/WindowsAssociationManager.cs b/osu.Game/Updater/WindowsAssociationManager.cs index 104406c81b..bb0e37a2f4 100644 --- a/osu.Game/Updater/WindowsAssociationManager.cs +++ b/osu.Game/Updater/WindowsAssociationManager.cs @@ -78,7 +78,7 @@ namespace osu.Game.Updater localisationParameters.ValueChanged += _ => updateDescriptions(); } - internal void InstallAssociations() + public void InstallAssociations() { try { @@ -132,7 +132,9 @@ namespace osu.Game.Updater } } - internal void UninstallAssociations() + public void UninstallAssociations() => UninstallAssociations(programIdPrefix); + + public static void UninstallAssociations(string programIdPrefix) { try { @@ -154,7 +156,7 @@ namespace osu.Game.Updater } } - internal void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); + internal static void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); #region Native interop