Added check for null when removing registry keys

This commit is contained in:
Alexander 2018-12-27 00:31:01 +02:00
parent 898427b26a
commit 1eac6001ab

View file

@ -1,6 +1,8 @@
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
@ -100,14 +102,15 @@ private static void DissociateExtension(string applicationExecutablePath, string
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes", true);
key.DeleteSubKeyTree(extension + "_auto_file");
key.DeleteSubKeyTree("." + extension);
}
catch (Exception)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Classes", true);
RegistryKey subKeyTree = Registry.CurrentUser.OpenSubKey(@"Software\Classes\" + extension + "_auto_file", true);
if (subKeyTree != null)
{
key.DeleteSubKeyTree(extension + "_auto_file");
key.DeleteSubKeyTree("." + extension);
}
}
catch { }
}
private static void MenuIntegrate(string action)
@ -132,13 +135,14 @@ private static void MenuIntegrate(string action)
if (action == "disable")
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Classes\*\shell\", true);
key.DeleteSubKeyTree("Crypto Notepad");
RegistryKey subKeyTree = Registry.CurrentUser.OpenSubKey(@"Software\Classes\*\shell\Crypto Notepad", true);
if (subKeyTree != null)
{
key.DeleteSubKeyTree("Crypto Notepad");
}
}
}
catch (Exception)
{
}
catch { }
}
/*Functions*/