-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRegKey.h
More file actions
151 lines (117 loc) · 5.83 KB
/
RegKey.h
File metadata and controls
151 lines (117 loc) · 5.83 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
#pragma once
#include "RegPath.h"
NS_BEGIN
// Forward declarations
class CRegKey;
class CDoubleNullStrW;
//#################################################################################################
class CRegBuf final
{
private:
friend class CRegKey;
public:
CRegBuf(void);
CRegBuf(const CRegBuf &src);
CRegBuf(CRegBuf &&src) noexcept;
explicit CRegBuf(const size_t nBufSize);
~CRegBuf(void);
CRegBuf &operator=(const CRegBuf &src);
CRegBuf &operator=(CRegBuf &&src) noexcept;
bool Alloc(const size_t nBufSize);
void Free(void);
void Empty(void);
bool IsEmpty(void) const noexcept;
operator PWSTR(void) const noexcept;
operator PBYTE(void) const noexcept;
PBYTE GetBuffer(void) const noexcept;
size_t GetBufSize(void) const noexcept;
size_t GetDataSize(void) const noexcept;
DWORD GetDataType(void) const noexcept;
private:
PBYTE m_pBuf;
size_t m_nBufSize;
size_t m_nDataSize;
DWORD m_dwDataType;
};
//#################################################################################################
class CRegKey final
{
public:
CRegKey(void);
CRegKey(const CRegKey &src);
CRegKey(CRegKey &&src) noexcept;
~CRegKey(void);
// Open a registry key from the native hive (64 on 64-bit and 32 on 32-bit)
ERRCODE Open(const CRegPath &path, const REGSAM sam = KEY_READ);
ERRCODE Open(const HKEY hKey, PCWSTR szKey, const REGSAM sam = KEY_READ);
ERRCODE Open(const CRegKey ®key, PCWSTR szKey, const REGSAM sam = KEY_READ);
ERRCODE Open(PCWSTR szKey, const REGSAM sam, CRegKey ®key);
// Open a registry key from the 32-bit hive
ERRCODE Open32(const CRegPath &path, const REGSAM sam = KEY_READ);
ERRCODE Open32(const HKEY hKey, PCWSTR szKey, const REGSAM sam = KEY_READ);
ERRCODE Open32(const CRegKey ®key, PCWSTR szKey, const REGSAM sam = KEY_READ);
ERRCODE Open32(PCWSTR szKey, const REGSAM sam, CRegKey ®key);
// Open a registry key from the 64-bit hive
ERRCODE Open64(const CRegPath &path, const REGSAM sam = KEY_READ);
ERRCODE Open64(const HKEY hKey, PCWSTR szKey, const REGSAM sam = KEY_READ);
ERRCODE Open64(const CRegKey ®key, PCWSTR szKey, const REGSAM sam = KEY_READ);
ERRCODE Open64(PCWSTR szKey, const REGSAM sam, CRegKey ®key);
// Creates a registry key in the native hive (64 on 64-bit and 32 on 32-bit)
ERRCODE Create(const CRegPath &path, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create(const HKEY hKey, PCWSTR szKey, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create(const CRegKey ®key, PCWSTR szKey, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create(PCWSTR szKey, const REGSAM sam, PDWORD pdwDisposition, CRegKey ®key);
// Creates a registry key in the 32-bit hive
ERRCODE Create32(const CRegPath &path, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create32(const HKEY hKey, PCWSTR szKey, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create32(const CRegKey ®key, PCWSTR szKey, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create32(PCWSTR szKey, const REGSAM sam, PDWORD pdwDisposition, CRegKey ®key);
// Creates a registry key in the 64-bit hive
ERRCODE Create64(const CRegPath &path, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create64(const HKEY hKey, PCWSTR szKey, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create64(const CRegKey ®key, PCWSTR szKey, const REGSAM sam = KEY_READ | KEY_WRITE, PDWORD pdwDisposition = nullptr);
ERRCODE Create64(PCWSTR szKey, const REGSAM sam, PDWORD pdwDisposition, CRegKey ®key);
ERRCODE DeleteKey(PCWSTR szKey) const;
ERRCODE DeleteKey32(PCWSTR szKey) const;
ERRCODE DeleteKey64(PCWSTR szKey) const;
static bool CreateTree(const CRegPath &path);
static bool CreateTree32(const CRegPath &path);
static bool CreateTree64(const CRegPath &path);
static bool DeleteTree(const CRegPath &path);
static bool DeleteTree32(const CRegPath &path);
static bool DeleteTree64(const CRegPath &path);
CRegKey &Attach(HKEY hKey);
HKEY Detach(void);
CRegKey &operator=(const CRegKey &src);
CRegKey &operator=(CRegKey &&src) noexcept;
void Assign(const CRegKey ®key);
void Close(void);
bool IsOpen(void) const noexcept;
operator HKEY(void) const noexcept;
bool KeyExists(PCWSTR szKey) const;
bool ValueExists(PCWSTR szValue) const;
size_t GetKeyCount(void) const;
ERRCODE EnumKey(CRegBuf ®buf, DWORD &dwIndex) const;
size_t GetValueCount(void) const;
ERRCODE EnumValue(CRegBuf ®buf, DWORD &dwIndex) const;
ERRCODE DeleteValue(PCWSTR szValue) const;
ERRCODE GetValue(PCWSTR szValue, CRegBuf ®buf) const;
ERRCODE GetValue(PCWSTR szValue, CStrW &strData, bool *pbExpandSz = nullptr) const;
ERRCODE GetValue(PCWSTR szValue, DWORD &nData) const;
ERRCODE GetValue(PCWSTR szValue, uint64_t &nData) const;
ERRCODE GetValue(PCWSTR szValue, CDoubleNullStrW &strData) const;
ERRCODE SetValue(PCWSTR szValue, const DWORD dwType, PCBYTE pData, const size_t nDataSize) const;
ERRCODE SetValue(PCWSTR szValue, const CRegBuf ®buf) const;
ERRCODE SetValue(PCWSTR szValue, const CStrW &strData, const bool bExpandSz = false) const;
ERRCODE SetValue(PCWSTR szValue, PCWSTR szData, const size_t nStrLen = -1, const bool bExpandSz = false) const;
ERRCODE SetValue(PCWSTR szValue, const DWORD nData) const;
ERRCODE SetValue(PCWSTR szValue, const uint64_t nData) const;
ERRCODE SetValue(PCWSTR szValue, const CDoubleNullStrW &strData) const;
ERRCODE DisableReflection(void) const;
ERRCODE EnableReflection(void) const;
bool IsReflected(void) const;
ERRCODE Flush(void) const;
private:
HKEY m_hKey;
};
NS_END