using Microsoft.Win32; namespace ClassNotify.Setup.Services; public class RegistryUninstallManager { private const string UninstallRoot = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ClassNotify"; public static void RegisterUninstall(string installDir, string uninstallExePath, string clientExePath) { try { using var key = Registry.LocalMachine.CreateSubKey(UninstallRoot); if (key == null) return; key.SetValue("DisplayName", "ClassNotify 教室大屏播报终端"); key.SetValue("DisplayVersion", "2.2.0"); key.SetValue("Publisher", "ClassNotify Inc."); key.SetValue("InstallLocation", installDir); key.SetValue("UninstallString", $"\"{uninstallExePath}\" /uninstall"); key.SetValue("DisplayIcon", $"\"{clientExePath}\",0"); key.SetValue("NoModify", 1, RegistryValueKind.DWord); key.SetValue("NoRepair", 0, RegistryValueKind.DWord); } catch { } } public static void UnregisterUninstall() { try { Registry.LocalMachine.DeleteSubKeyTree(UninstallRoot, throwOnMissingSubKey: false); } catch { } } }