forked from koron/ABrowser
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CReg.cpp
137 lines (114 loc) · 3.42 KB
/
CReg.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
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
// レジストリオブジェクト since 1997.09.01
// CReg.cpp:ClassRegistoryコード Written by KoRoN
// Version 1.00
// 1997.09.01
// Last Change: 01:18:13 25-Sep-2000.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "CReg.h"
// コンストラクタ /////////////////////////////////////////////////////////1.00
ClassRegistory::ClassRegistory(char* pszKeyName, HKEY hKey)
{
DWORD dwDisposition;
nErrorCode = RegCreateKeyEx(
hKey,
pszKeyName,
NULL,
"",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&(ClassRegistory::hKey),
&dwDisposition
);
nErrorCode = NULL;
}
//////////////////////////////////////////////KoRoN/1997.09.01/KoRoN/1997.09.01
// デストラクタ ///////////////////////////////////////////////////////////1.00
ClassRegistory::~ClassRegistory()
{
RegCloseKey(hKey);
}
//////////////////////////////////////////////KoRoN/1997.09.01/KoRoN/1997.09.01
// GetErrorCode ///////////////////////////////////////////////////////////1.00
long ClassRegistory::GetErrorCode()
{
return nErrorCode;
}
//////////////////////////////////////////////KoRoN/1997.09.01/KoRoN/1997.09.01
// SetValue(DWORD) ////////////////////////////////////////////////////////1.01
long
ClassRegistory::SetValue(char *pszValueName, DWORD dwValue)
{
nErrorCode = RegSetValueEx(
hKey,
pszValueName,
0,
REG_DWORD,
(CONST BYTE *)&dwValue,
sizeof(DWORD)
);
return nErrorCode == ERROR_SUCCESS ? CREG_SUCCESS : CREG_ERROR;
}
//////////////////////////////////////////////KoRoN/1997.09.01/KoRoN/1997.09.01
// GetValue(DWORD) ////////////////////////////////////////////////////////1.00
long
ClassRegistory::GetValue(char *pszValueName, DWORD *dwValue)
{
DWORD dwType = REG_DWORD;
DWORD dwSize = sizeof(DWORD);
nErrorCode = RegQueryValueEx(
hKey,
pszValueName,
NULL,
&dwType,
(LPBYTE)dwValue,
&dwSize
);
if (nErrorCode != ERROR_SUCCESS)
return CREG_ERROR;
return CREG_SUCCESS;
}
//////////////////////////////////////////////KoRoN/1997.09.01/KoRoN/1997.09.01
// SetValue(char*) ////////////////////////////////////////////////////////1.00
long ClassRegistory::SetValue(char *pszValueName, char *pszValue)
{
nErrorCode = RegSetValueEx(
hKey,
pszValueName,
0,
REG_SZ,
(CONST BYTE *)pszValue,
lstrlen(pszValue)
);
if (nErrorCode != ERROR_SUCCESS) return CREG_ERROR;
return CREG_SUCCESS;
}
//////////////////////////////////////////////KoRoN/1997.09.01/KoRoN/1997.09.01
// GetValue(char*) ////////////////////////////////////////////////////////1.00
long ClassRegistory::GetValue(char *pszValueName,
char *pszValue, DWORD dwSize)
{
DWORD dwType = REG_SZ;
nErrorCode = RegQueryValueEx(
hKey,
pszValueName,
NULL,
&dwType,
(LPBYTE)pszValue,
&dwSize
);
if (nErrorCode != ERROR_SUCCESS) return CREG_ERROR;
return CREG_SUCCESS;
}
//////////////////////////////////////////////KoRoN/1997.09.01/KoRoN/1997.09.01
// Flush() ////////////////////////////////////////////////////////////////1.00
long
ClassRegistory::FlushKey()
{
return ::RegFlushKey(hKey);
}
//////////////////////////////////////////////KoRoN/2000.09.24/KoRoN/2000.09.24
// ///////////////////////////////////////////////////////////////////////1.00
//////////////////////////////////////////////KoRoN/2000.09.24/KoRoN/2000.09.24
// vi:ts=4 sts=4 sw=4 tw=0