改了一亿个东西,修了一亿个 BUG
This commit is contained in:
28
Utils/RegistryUtils.cs
Normal file
28
Utils/RegistryUtils.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
|
||||
namespace AnotherReplayReader.Utils
|
||||
{
|
||||
internal static class RegistryUtils
|
||||
{
|
||||
public static string? Retrieve(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;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Instance.DebugMessage += $"Failed to retrieve registy {hive}:{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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user