mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +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)
|
internal static void DeleteFileAssociationViaRegistry(string ext, string appName)
|
||||||
{
|
{
|
||||||
|
var appExtensionRegKey = $"{appName}{ext}";
|
||||||
using (var registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Classes\", true))
|
using (var registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Classes\", true))
|
||||||
{
|
{
|
||||||
if (registryKey?.OpenSubKey($"{appName}{ext}") != null)
|
if (registryKey?.OpenSubKey(appExtensionRegKey) != null)
|
||||||
{
|
{
|
||||||
registryKey.DeleteSubKeyTree($"{appName}{ext}");
|
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()
|
internal static void Refresh()
|
||||||
|
Loading…
Reference in New Issue
Block a user