feat: add GetGamePath (xbox only)

This commit is contained in:
2026-06-18 15:27:10 -03:00
parent 14ad0fbbbf
commit ad90304f5e
+35
View File
@@ -0,0 +1,35 @@
using Microsoft.Win32;
internal static class Utils
{
public static string? GetGamePath()
{
string? path;
path = TryGetXboxPath();
return path;
/*
* to-do:
* implement steam and epic
*/
}
private static string? TryGetXboxPath()
{
const string keyPath = @"Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages";
using RegistryKey? key = Registry.CurrentUser.OpenSubKey(keyPath);
if (key == null) return null;
string? match = key.GetSubKeyNames().FirstOrDefault(n => n.StartsWith(Constants.PackageName, StringComparison.OrdinalIgnoreCase));
if (match == null) return null;
using RegistryKey? subKey = key.OpenSubKey(match);
if (subKey == null) return null;
object? pkgRootFolder = subKey.GetValue("PackageRootFolder");
if (pkgRootFolder == null) return null;
return pkgRootFolder.ToString();
}
}