mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Merge pull request #8876 from ivandrofly/association-delete
Delete associated registry value when removing file association
This commit is contained in:
commit
0accb7ccdc
@ -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()
|
||||
@ -112,4 +124,4 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
SHChangeNotify(0x08000000, 0x2000, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user