DCL 3.7.4
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__DCL_BEGIN_NAMESPACE
21
22#if __DCL_HAVE_THIS_FILE__
23 #undef __THIS_FILE__
24 static const char_t __szWinRegistry_h__[] = __T("dcl/Registry.h");
25 #define __THIS_FILE__ __szWinRegistry_h__
26#endif
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 String getString(const String& strName)
59
60 int getInteger(const String& strName)
62
63 void setValue(const String& strName, const String& strValue)
65
66 void setValue(const String& strName, int nValue);
68
69 HKEY parentKey() const;
70 HKEY key() const;
71 REGSAM sam() const;
72 const String& keyName() const;
73 bool opened() const;
74 bool existsValue(const String& strName);
75 bool existsSubKey(const String& strKey) const;
76 static bool existsKey(const String& strKeyName, HKEY hParentKey);
77
78protected:
80 HKEY __hKey;
82 String __strKey;
83
84 LONG getDataInfo(const String& strName, REGISTRY_DATAINFO& info);
85};
86
87inline HKEY Registry::parentKey() const
88{
89 return __hParentKey;
90}
91
92inline HKEY Registry::key() const
93{
94 __DCL_ASSERT(opened());
95 return __hKey;
96}
97
98inline REGSAM Registry::sam() const
99{
100 __DCL_ASSERT(opened());
101 return __samDesired;
102}
103
104inline const String& Registry::keyName() const
105{
106 __DCL_ASSERT(opened());
107 return __strKey;
108}
109
110inline bool Registry::opened() const
111{
112 return __hKey != NULL;
113}
114
115inline bool Registry::existsSubKey(const String& strKey) const
116{
117 return Registry::existsKey(strKey, __hKey);
118}
119
120#if __DCL_HAVE_THIS_FILE__
121 #undef __THIS_FILE__
122 #define __THIS_FILE__ __T(__FILE__)
123#endif
124
125__DCL_END_NAMESPACE
126
127#endif // __DCL_REGISTRY_H__
#define NULL
Definition Config.h:312
#define DCLCAPI
Definition Config.h:95
wchar_t char_t
Definition Config.h:247
#define __DCL_THROWS1(e)
Definition Config.h:152
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:227
#define __DCL_ASSERT(expr)
Definition Object.h:394
#define __T(str)
Definition Object.h:60
__DCL_BEGIN_NAMESPACE struct _REGISTRY_DATAINFO REGISTRY_DATAINFO
Object()
Definition Object.cpp:183
REGSAM __samDesired
Definition Registry.h:81
LONG getDataInfo(const String &strName, REGISTRY_DATAINFO &info)
HKEY __hKey
Definition Registry.h:80
String __strKey
Definition Registry.h:82
HKEY __hParentKey
Definition Registry.h:79