Repository navigation
Expand file tree
/
Copy pathregistry.cs
More file actions
159 lines (148 loc) · 4.15 KB
/
Copy pathregistry.cs
File metadata and controls
159 lines (148 loc) · 4.15 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
namespace PDF_Convert
{
using Microsoft.Win32;
using System;
internal class registry
{
public readonly int READ_ERROR = -9999;
private string reg_item;
public registry(string item)
{
this.reg_item = item;
}
private bool create_reg_item(string item)
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("software", true);
key.CreateSubKey(item);
key.Close();
return true;
}
catch
{
return false;
}
}
public byte[] get_reg_byte(string item)
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"software\" + this.reg_item, false);
byte[] buffer = (byte[]) key.GetValue(item);
key.Close();
return buffer;
}
catch
{
return null;
}
}
public int get_reg_int(string item)
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"software\" + this.reg_item, false);
int num = System.Convert.ToInt32(key.GetValue(item));
key.Close();
return num;
}
catch
{
return this.READ_ERROR;
}
}
public string get_reg_string(string item)
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"software\" + this.reg_item, false);
string str = key.GetValue(item).ToString();
key.Close();
return str;
}
catch
{
return "";
}
}
public bool is_reg_exist(string item)
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("software", false);
string[] subKeyNames = key.GetSubKeyNames();
foreach (string str in subKeyNames)
{
if (item == str)
{
goto Label_005C;
}
}
key.Close();
return false;
Label_005C:
key.Close();
return true;
}
catch
{
return false;
}
}
public bool set_reg_byte(string item, ref byte[] data)
{
try
{
if (!this.is_reg_exist(this.reg_item))
{
this.create_reg_item(this.reg_item);
}
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"software\" + this.reg_item, true);
key.SetValue(item, data);
key.Close();
return true;
}
catch
{
return false;
}
}
public bool set_reg_int(string item, int data)
{
try
{
if (!this.is_reg_exist(this.reg_item))
{
this.create_reg_item(this.reg_item);
}
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"software\" + this.reg_item, true);
key.SetValue(item, data);
key.Close();
return true;
}
catch
{
return false;
}
}
public bool set_reg_string(string item, string data)
{
try
{
if (!this.is_reg_exist(this.reg_item))
{
this.create_reg_item(this.reg_item);
}
RegistryKey key = Registry.CurrentUser.OpenSubKey("software" + this.reg_item, true);
key.SetValue(item, data);
key.Close();
return true;
}
catch
{
return false;
}
}
}
}