mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +01:00
Delete associated registry value when removing file association
Enhanced the `DeleteFileAssociationViaRegistry` method to also delete the default registry value associated with the file extension if it matches the given application extension. This ensures a more thorough cleanup of file type associations in the registry. Signed-off-by: Ivandro Jao <Ivandrofly@gmail.com>
This commit is contained in:
parent
4ebe2da219
commit
ffcc9343bf
@ -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