-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegistryManager.cs
39 lines (35 loc) · 1.1 KB
/
RegistryManager.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
29
30
31
32
33
34
35
36
37
38
39
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Security;
using System.Text;
using System.Windows.Forms;
namespace LSRVersionManager
{
public class RegistryManager
{
public RegistryKey key;
public RegistryManager()
{
try
{
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\LEGO Media\LEGO Stunt Rally", true);
if (key == null) key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\LEGO Media\LEGO Stunt Rally", true);
}
catch (SecurityException)
{
MessageBox.Show("I don't have permission to edit registry keys! Try opening with Administrator?", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
public object ReadKey(string keyName)
{
return key?.GetValue(keyName);
}
public void WriteKey(string keyName, object value)
{
key?.SetValue(keyName, value);
}
}
}