forked from miljbee/PS3BluMote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegUtils.cs
96 lines (89 loc) · 2.81 KB
/
RegUtils.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace PS3BluMote
{
public static class RegUtils
{
private static List<RegistryKey> FindResult = new List<RegistryKey>();
private static void Find(RegistryKey key, string skFilter, string keyName)
{
if (key.Name.Contains(skFilter))
{
foreach (string vn in key.GetValueNames())
{
if (vn == keyName)
{
FindResult.Add(key);
break;
}
}
}
foreach (string skn in key.GetSubKeyNames())
{
try
{
Find(key.OpenSubKey(skn), skFilter, keyName);
}
catch { }
}
}
public static List<RegistryKey> GetKeys(RegistryKey key, string skFilter, string keyName)
{
List<RegistryKey> result = new List<RegistryKey>();
FindResult.Clear();
Find(key, skFilter, keyName);
foreach (RegistryKey rk in FindResult) result.Add(rk);
FindResult.Clear();
return result;
}
public static string GetDevConnectedSound()
{
try
{
return (string)Registry.GetValue(@"HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceConnect\.Current", "", "");
}
catch
{
DebugLog.write("RegUtils.GetDevConnectedSound() Failed");
return null;
}
}
public static string GetDevDisconnectedSound()
{
try
{
return (string)Registry.GetValue(@"HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceDisconnect\.Current", "", "");
}
catch
{
DebugLog.write("RegUtils.GetDevConnectedSound Failed");
return null;
}
}
public static void SetDevConnectedSound(string sound)
{
try
{
Registry.SetValue(@"HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceConnect\.Current", "", sound);
}
catch
{
DebugLog.write("RegUtils.SetDevConnectedSound Failed");
}
}
public static void SetDevDisconnectedSound(string sound)
{
try
{
Registry.SetValue(@"HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceDisconnect\.Current", "", sound);
}
catch
{
DebugLog.write("RegUtils.SetDevDisconnectedSound Failed");
}
}
}
}