vregistry.h
4.17 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
/*
Wrapper for the Windows Registry
Version: 1.0
Modified on: 8-20-2009
Created with: QT 4.5 and QT Creator 1.2
Tested on: Windows XP SP3
Bryan Cairns
*/
#include <QObject>
#if defined(Q_OS_WIN)
#ifndef VREGISTRY_H
#define VREGISTRY_H
#include "windows.h"
#include <QString>
#include <QByteArray>
#include <QStringList>
namespace voidrealms
{
namespace win32
{
class VRegistry
{
private:
HKEY mKey; //The current opened key
bool mOpen; //Boolean indicates if the registry is open
//////////////////////////////////////////////////////////////////////////////////////
// Windows API Methods
//////////////////////////////////////////////////////////////////////////////////////
//Opens a Registry Key
bool OpenKey(HKEY RootKey,LPCTSTR SubKey);
//Creates a registry key and opens it
bool CreateKey(HKEY RootKey,LPCTSTR SubKey);
//Deletes a registry key and all values
bool DeleteKey(HKEY RootKey,LPCTSTR SubKey);
//Determines if the key exists
bool KeyExists(HKEY RootKey,LPCTSTR SubKey);
//Deletes a registry value and all values
bool DeleteValue(LPCTSTR ValueName);
//Determines if a value exists
bool ValueExists(LPCTSTR ValueName);
//Gets a Pointer to a Byte array filled with a reg type value from an open key (be sure to delete[] mVar)
BYTE* QueryValue(LPCTSTR ValueName, DWORD ValueType);
//Sets a value in the regsitry
bool SetValue(LPCTSTR ValueName, DWORD ValueType, BYTE* Value, DWORD dwSize);
public:
//////////////////////////////////////////////////////////////////////////////////////
// QT friendly Methods
//////////////////////////////////////////////////////////////////////////////////////
//Returns a boolean indicating if the Registry is open
bool isOpen();
//Closes the Registry Key
bool CloseKey();
//Opens a Registry Key
bool OpenKey(HKEY RootKey,QString SubKey);
//Creates a registry key and opens it
bool CreateKey(HKEY RootKey,QString SubKey);
//Deletes a registry key and all values
bool DeleteKey(HKEY RootKey,QString SubKey);
//Determines if the key exists
bool KeyExists(HKEY RootKey,QString SubKey);
//Deletes a registry value and all values
bool DeleteValue(QString ValueName);
//Determines if a value exists
bool ValueExists(QString ValueName);
//Gets a REG_SZ value as a QString
QString get_REG_SZ(QString ValueName);
//Gets a REG_EXPAND_SZ value as a QString
QString get_REG_EXPAND_SZ(QString ValueName);
//Gets a REG_DWORD value as a UINT
uint get_REG_DWORD(QString ValueName);
//Gets a REG_BINARY value as a QByteArray
QByteArray get_REG_BINARY(QString ValueName);
//Gets a REG_MUTLI_SZ value as a QStringList
QStringList get_MULTI_SZ(QString ValueName);
//Sets a REG_SZ value with a QString
bool set_REG_SZ(QString ValueName, QString Value);
//Sets a REG_EXPAND_SZ value with a QString
bool set_REG_EXPAND_SZ(QString ValueName, QString Value);
//Sets a REG_DWORD value with a UINT
bool set_REG_DWORD(QString ValueName, UINT Value);
//Sets a REG_BINARY value with a QByteArray
bool set_REG_BINARY(QString ValueName, QByteArray Value);
//Sets a REG_MULTI_SZ value with a QStringList
bool set_REG_MULTI_SZ(QString ValueName, QStringList Value);
//Gets a string list filled with names of the sub keys from the current open key
QStringList enum_Keys();
//Gets a string list filled with names of the values from the current open key
QStringList enum_Values();
};
} //end voidrealms::win32 namespace
} //end voidrealms namespace
#endif // VREGISTRY_H
#endif // defined(Q_OS_WIN)