Merge pull request #8876 from ivandrofly/association-delete

Delete associated registry value when removing file association
This commit is contained in:
Nikolaj Olsson 2024-10-03 17:07:30 +02:00 committed by GitHub
commit 0accb7ccdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,13 +97,25 @@ namespace Nikse.SubtitleEdit.Logic
internal static void DeleteFileAssociationViaRegistry(string ext, string appName)
{
var appExtensionRegKey = $"{appName}{ext}";
using (var registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Classes\", true))
{
if (registryKey?.OpenSubKey($"{appName}{ext}") != null)
if (registryKey?.OpenSubKey(appExtensionRegKey) != null)
{
registryKey.DeleteSubKeyTree($"{appName}{ext}");
}
}
// (Default)
const string defaultRegValueName = "";
using (var registryKey = Registry.CurrentUser.OpenSubKey("Software\\Classes\\" + ext, true))
{
var registryValue = registryKey?.GetValue(defaultRegValueName);
if (appExtensionRegKey.Equals((string)registryValue, StringComparison.Ordinal))
{
registryKey.DeleteValue(defaultRegValueName);
}
}
}
internal static void Refresh()