Fixed a issue where the Installer crashed when a invalid path is in registry.

This commit is contained in:
2021-06-19 22:12:44 +02:00
parent e43782cfd6
commit 236de72895
2 changed files with 24 additions and 9 deletions

View File

@@ -13,13 +13,19 @@ namespace EZPPClient_Installer
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
if (key != null && key.GetSubKeyNames() != null)
{
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
foreach (string subkey_name in key.GetSubKeyNames())
{
if ((string)subkey.GetValue("DisplayName") == "osu!")
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
{
path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString());
if (subkey != null)
{
if ((string)subkey.GetValue("DisplayName") == "osu!")
{
path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString());
}
}
}
}
}
@@ -29,13 +35,19 @@ namespace EZPPClient_Installer
{
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(second_registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
if (key != null && key.GetSubKeyNames() != null)
{
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
foreach (string subkey_name in key.GetSubKeyNames())
{
if ((string)subkey.GetValue("DisplayName") == "osu!")
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
{
path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString());
if (subkey != null)
{
if ((string)subkey.GetValue("DisplayName") == "osu!")
{
path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString());
}
}
}
}
}