fix install path get

This commit is contained in:
辉鸭蛋 2024-12-27 02:37:46 +08:00
parent 1214ca2d65
commit c9634abebb
2 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using BetterGenshinImpact.GameTask.Common;
using Microsoft.Extensions.Logging;
using Microsoft.Win32;
@ -17,19 +18,19 @@ public class RegistryGameLocator
var cn = Registry.GetValue($@"HKEY_CURRENT_USER\Software\miHoYo\HYP\1_1\hk4e_cn", "GameInstallPath", null) as string;
if (!string.IsNullOrEmpty(cn))
{
return cn;
return Path.Combine(cn, "YuanShen.exe");
}
var global = Registry.GetValue($@"HKEY_CURRENT_USER\Software\Cognosphere\HYP\1_0\hk4e_global", "GameInstallPath", null) as string;
if (!string.IsNullOrEmpty(global))
{
return global;
return Path.Combine(global, "GenshinImpact.exe");
}
var bilibili = Registry.GetValue($@"HKEY_CURRENT_USER\Software\miHoYo\HYP\standalone\14_0\hk4e_bilibili\BilibiliGenshin\hk4e_bilibili", "GameInstallPath", null) as string;
var bilibili = Registry.GetValue($@"HKEY_CURRENT_USER\Software\miHoYo\HYP\standalone\14_0\hk4e_cn\umfgRO5gh5\hk4e_cn", "GameInstallPath", null) as string;
if (!string.IsNullOrEmpty(bilibili))
{
return bilibili;
return Path.Combine(bilibili, "YuanShen.exe");
}
}
catch (Exception e)

View File

@ -337,17 +337,17 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware, IVi
{
Task.Run(async () =>
{
var p1 = RegistryGameLocator.GetDefaultGameInstallPath();
var p1 = await UnityLogGameLocator.LocateSingleGamePathAsync();
if (!string.IsNullOrEmpty(p1))
{
Config.GenshinStartConfig.InstallPath = p1;
}
else
{
var path = await UnityLogGameLocator.LocateSingleGamePathAsync();
if (!string.IsNullOrEmpty(path))
var p2 = RegistryGameLocator.GetDefaultGameInstallPath();
if (!string.IsNullOrEmpty(p2))
{
Config.GenshinStartConfig.InstallPath = path;
Config.GenshinStartConfig.InstallPath = p2;
}
}
});