-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReg.cpp
86 lines (75 loc) · 1.78 KB
/
Reg.cpp
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
#include <windows.h>
#include "Reg.h"
bool Registry::OpenKey(HKEY key,LPCSTR SubKey)
{
if (RegOpenKeyEx(key,
(LPCTSTR) SubKey,
NULL,
KEY_ALL_ACCESS,
&m_hkey) == ERROR_SUCCESS) //Alles ok!
return true;
else
return false;
}
bool Registry::CloseKey()
{
if (RegCloseKey(m_hkey) == ERROR_SUCCESS)
return true;
else
return false;
}
bool Registry::GetValue(LPCSTR ValueName, LPTSTR szValue)
{
DWORD dwType;
DWORD dwSize = MAX_PATH;
if(RegQueryValueEx( m_hkey,
ValueName,
0,
&dwType,
(BYTE*)szValue,
&dwSize) == ERROR_SUCCESS)
return true;
else
return false;
}
bool Registry::SetValue(LPCTSTR ValueName, LPCSTR szValue)
{
if (RegSetValueEx( m_hkey,
ValueName,
0,
REG_SZ,
(BYTE *) szValue,
strlen(szValue)) == ERROR_SUCCESS)
return true;
else
return false;
}
bool Registry::DeleteValue(LPCTSTR ValueName)
{
if (RegDeleteValue(m_hkey, ValueName) == ERROR_SUCCESS)
return true;
else
return false;
}
bool Registry::DeleteKey(LPCTSTR KeyName)
{
if (RegDeleteKey(m_hkey, KeyName) == ERROR_SUCCESS)
return true;
else
return false;
}
bool Registry::CreateKey(HKEY hKey, LPCTSTR SubKey)
{
if (RegCreateKeyEx((HKEY)hKey,
SubKey,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&m_hkey,
NULL) == ERROR_SUCCESS)
return true;
else
return false;
}