DCL 4.0
Loading...
Searching...
No Matches
Registry.h
Go to the documentation of this file.
1#ifndef __DCL_REGISTRY_H__
2#define __DCL_REGISTRY_H__ 20080607
3
4#ifndef __DCL_CONFIG_H__
5#include <dcl/_Config.h>
6#endif
7
8#include <winreg.h>
9
10#ifndef __DCL_OBJECT_H__
11#include <dcl/Object.h>
12#endif
13#ifndef __DCL_EXCEPTION_H__
14#include <dcl/Exception.h>
15#endif
16#ifndef __DCL_STRING_H__
17#include <dcl/String.h>
18#endif
19
20#if __DCL_DEBUG
21static const char_t __szWinRegistry_h__[] = __T("dcl/Registry.h");
22#undef __THIS_FILE__
23#define __THIS_FILE__ __szWinRegistry_h__
24#endif
25
26__DCL_BEGIN_NAMESPACE
27
33
34class DCLCAPI Registry : public Object
35{
36 DECLARE_CLASSINFO(Registry)
37public:
38 Registry(HKEY hParentKey);
39
40 Registry(
41 HKEY hParentKey,
42 const String& strKey,
43 REGSAM samDesired = KEY_READ
45
46 virtual ~Registry();
47
48 void create(const String& strKey, REGSAM samDesired = KEY_ALL_ACCESS)
50
51 void open(const String& strKey, REGSAM samDesired = KEY_ALL_ACCESS)
53
54 void close()
56
57
58 String getString(const String& strName)
60
61 int getInteger(const String& strName)
63
64 void setValue(const String& strName, const String& strValue)
66
67 void setValue(const String& strName, int nValue);
69
70 HKEY parentKey() const;
71 HKEY key() const;
72 REGSAM sam() const;
73 const String& keyName() const;
74 bool opened() const;
75 bool existsValue(const String& strName);
76 bool existsSubKey(const String& strKey) const;
77 static bool existsKey(const String& strKeyName, HKEY hParentKey);
78
79protected:
81 HKEY m_hKey;
83 String m_strKey;
84
85 LONG getDataInfo(const String& strName, REGISTRY_DATAINFO& info);
86};
87
88
89inline HKEY Registry::parentKey() const
90{
91 return m_hParentKey;
92}
93
94inline HKEY Registry::key() const
95{
96 __DCL_ASSERT(opened());
97 return m_hKey;
98}
99
100inline REGSAM Registry::sam() const
101{
102 __DCL_ASSERT(opened());
103 return m_samDesired;
104}
105
106inline const String& Registry::keyName() const
107{
108 __DCL_ASSERT(opened());
109 return m_strKey;
110}
111
112inline bool Registry::opened() const
113{
114 return m_hKey != NULL;
115}
116
117inline bool Registry::existsSubKey(const String& strKey) const
118{
119 return Registry::existsKey(strKey, m_hKey);
120}
121
122
123__DCL_END_NAMESPACE
124
125#if __DCL_DEBUG
126#undef __THIS_FILE__
127#define __THIS_FILE__ __T(__FILE__)
128#endif
129
130#endif // __DCL_REGISTRY_H__
#define NULL
Definition Config.h:340
#define DCLCAPI
Definition Config.h:100
wchar_t char_t
Definition Config.h:275
#define __DCL_THROWS1(e)
Definition Config.h:167
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:210
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
__DCL_BEGIN_NAMESPACE struct _REGISTRY_DATAINFO REGISTRY_DATAINFO
void CharsetConvertException * setValue(UTF8Encoder::encode(_value), _assignType)
Object()
Definition Object.cpp:183
HKEY m_hParentKey
Definition Registry.h:80
REGSAM m_samDesired
Definition Registry.h:82
String m_strKey
Definition Registry.h:83
LONG getDataInfo(const String &strName, REGISTRY_DATAINFO &info)
HKEY m_hKey
Definition Registry.h:81