分离玩家信息插件,以及更新检测

This commit is contained in:
2021-10-22 08:54:04 +02:00
parent 2a96f8efac
commit 08700abd4f
25 changed files with 860 additions and 234 deletions

View File

@@ -3,15 +3,15 @@ using System;
namespace AnotherReplayReader.Utils
{
internal static class RegistryUtils
public static class RegistryUtils
{
public static string? Retrieve(RegistryHive hive, string path, string value)
public static string? Retrieve32(RegistryHive hive, string path, string value)
{
try
{
using var view32 = RegistryKey.OpenBaseKey(hive, RegistryView.Registry32);
using var ra3Key = view32.OpenSubKey(path, false);
return ra3Key?.GetValue(value) as string;
using var key = view32.OpenSubKey(path, false);
return key?.GetValue(value) as string;
}
catch (Exception e)
{
@@ -20,9 +20,24 @@ namespace AnotherReplayReader.Utils
}
}
public static string? RetrieveInHklm64(string path, string value)
{
try
{
using var view64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
using var key = view64?.OpenSubKey(path, false);
return key?.GetValue(value) as string;
}
catch (Exception e)
{
Debug.Instance.DebugMessage += $"Failed to retrieve registy HKLM64:{path}:{value}: {e}";
return null;
}
}
public static string? RetrieveInRa3(RegistryHive hive, string value)
{
return Retrieve(hive, @"Software\Electronic Arts\Electronic Arts\Red Alert 3", value);
return Retrieve32(hive, @"Software\Electronic Arts\Electronic Arts\Red Alert 3", value);
}
}
}