-
Notifications
You must be signed in to change notification settings - Fork 0
/
Registry.cs
28 lines (26 loc) · 1.14 KB
/
Registry.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using Microsoft.Win32;
namespace RA34GBPatchInstaller
{
class Registry
{
public static string GetRA3Path()
{
using var view32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
using var ra3 = view32.OpenSubKey("Software\\Electronic Arts\\Electronic Arts\\Red Alert 3");
return ra3?.GetValue("Install Dir") as string ?? string.Empty;
}
public static void SetRA3Path(string path)
{
using var view32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
using var ra3 = view32.OpenSubKey("Software\\Electronic Arts\\Electronic Arts\\Red Alert 3", writable: true);
if (ra3 == null)
{
using var newra3 = view32.CreateSubKey("Software\\Electronic Arts\\Electronic Arts\\Red Alert 3", writable: true);
newra3.SetValue("Install Dir", path, RegistryValueKind.String);
newra3.SetValue("UseLocalUserMap", 0, RegistryValueKind.DWord);
return;
}
ra3.SetValue("Install Dir", path);
}
}
}