EZPPClient-Installer/EZPPClient Installer/Util.cs

55 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Path = System.IO.Path;
using File = System.IO.File;
using Microsoft.Win32;
namespace EZPPClient_Installer
{
class Util
{
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;
}
}
}