EZPPClient-Installer/EZPPClient Installer/Utils/OsuUtil.cs

49 lines
1.4 KiB
C#

using Path = System.IO.Path;
using Microsoft.Win32;
namespace EZPPClient_Installer
{
class OsuUtil
{
public static string osuInstallDir()
{
string path = "";
string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
string second_registry_key = @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
{
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
{
if ((string)subkey.GetValue("DisplayName") == "osu!")
{
path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString());
}
}
}
}
if (string.IsNullOrEmpty(path))
{
using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(second_registry_key))
{
foreach (string subkey_name in key.GetSubKeyNames())
{
using (RegistryKey subkey = key.OpenSubKey(subkey_name))
{
if ((string)subkey.GetValue("DisplayName") == "osu!")
{
path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString());
}
}
}
}
}
return path;
}
}
}