]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/msw/registry.h
various misc ifacecheck fixes (many virtual attributes missing)
[wxWidgets.git] / interface / wx / msw / registry.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: msw/registry.h
e54c96f1 3// Purpose: interface of wxRegKey
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxRegKey
7c913512 11
23324ae1
FM
12 wxRegKey is a class representing the Windows registry (it is only available
13 under Windows). One can create, query and delete registry keys using this
14 class.
7c913512 15
23324ae1
FM
16 The Windows registry is easy to understand. There are five registry keys,
17 namely:
7c913512 18
9602ce3d
BP
19 @li @c HKEY_CLASSES_ROOT (HKCR)
20 @li @c HKEY_CURRENT_USER (HKCU)
21 @li @c HKEY_LOCAL_MACHINE (HKLM)
22 @li @c HKEY_CURRENT_CONFIG (HKCC)
23 @li @c HKEY_USERS (HKU)
7c913512 24
23324ae1 25 After creating a key, it can hold a value. The values can be:
7c913512 26
bbc5b7f8
BP
27 @li String Value
28 @li Binary Value
29 @li DWORD Value
30 @li Multi String Value
31 @li Expandable String Value
7c913512 32
d9faa1fe 33 @onlyfor{wxmsw}
7c913512 34
23324ae1 35 @library{wxbase}
bbc5b7f8
BP
36 @category{misc}
37
38 @b Example:
39
40 @code
41 wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey");
42
43 // Create the key if it does not exist.
44 if( !key->Exists() )
45 key->Create();
46
47 // Create a new value "MYVALUE" and set it to 12.
48 key->SetValue("MYVALUE", 12);
49
50 // Read the value back.
51 long value;
52 key->QueryValue("MYVALUE", &value);
53 wxMessageBox(wxString::Format("%d", value), "Registry Value", wxOK);
54
55 // Get the number of subkeys and enumerate them.
56 size_t subkeys;
57 key->GetKeyInfo(&subkeys, NULL, NULL, NULL);
58
59 wxString key_name;
60 key->GetFirstKey(key_name, 1);
61 for(int i = 0; i < subkeys; i++)
62 {
63 wxMessageBox(key_name, "Subkey Name", wxOK);
64 key->GetNextKey(key_name, 1);
65 }
66 @endcode
23324ae1 67*/
7c913512 68class wxRegKey
23324ae1
FM
69{
70public:
23324ae1 71 /**
9602ce3d 72 Default constructor, initializes to @c HKEY_CLASSES_ROOT.
23324ae1
FM
73 */
74 wxRegKey();
bbc5b7f8
BP
75 /**
76 The constructor to set the full name of the key.
77 */
7c913512 78 wxRegKey(const wxString& strKey);
bbc5b7f8
BP
79 /**
80 The constructor to set the full name of the key under a previously created
81 parent.
82 */
7c913512 83 wxRegKey(const wxRegKey& keyParent, const wxString& strKey);
bbc5b7f8
BP
84
85 /**
86 Access modes for wxRegKey.
87 */
88 enum AccessMode
89 {
90 Read, ///< Read-only
91 Write ///< Read and Write
92 };
23324ae1
FM
93
94 /**
95 Closes the key.
96 */
97 void Close();
98
99 /**
4cc4bfaf 100 Creates the key. Will fail if the key already exists and @a bOkIfExists is
23324ae1
FM
101 @false.
102 */
4cc4bfaf 103 bool Create(bool bOkIfExists = true);
23324ae1
FM
104
105 /**
106 Deletes the subkey with all of its subkeys/values recursively.
107 */
4cc4bfaf 108 void DeleteKey(const wxChar* szKey);
23324ae1
FM
109
110 /**
111 Deletes this key and all of its subkeys and values recursively.
112 */
113 void DeleteSelf();
114
115 /**
116 Deletes the named value.
117 */
4cc4bfaf 118 void DeleteValue(const wxChar* szKey);
23324ae1
FM
119
120 /**
121 Returns @true if the key exists.
122 */
bbc5b7f8 123 bool Exists() const;
23324ae1
FM
124
125 /**
126 Gets the first key.
127 */
128 bool GetFirstKey(wxString& strKeyName, long& lIndex);
129
130 /**
131 Gets the first value of this key.
132 */
133 bool GetFirstValue(wxString& strValueName, long& lIndex);
134
135 /**
136 Gets information about the key.
d9faa1fe 137
7c913512 138 @param pnSubKeys
4cc4bfaf 139 The number of subkeys.
7c913512 140 @param pnMaxKeyLen
4cc4bfaf 141 The maximum length of the subkey name.
7c913512 142 @param pnValues
4cc4bfaf 143 The number of values.
7c913512 144 @param pnMaxValueLen
4cc4bfaf 145 The maximum length of a value.
23324ae1 146 */
bbc5b7f8
BP
147 bool GetKeyInfo(size_t* pnSubKeys, size_t* pnMaxKeyLen,
148 size_t* pnValues, size_t* pnMaxValueLen) const;
23324ae1
FM
149
150 /**
151 Gets the name of the registry key.
152 */
328f5751 153 wxString GetName(bool bShortPrefix = true) const;
23324ae1
FM
154
155 /**
156 Gets the next key.
157 */
328f5751 158 bool GetNextKey(wxString& strKeyName, long& lIndex) const;
23324ae1
FM
159
160 /**
161 Gets the next key value for this key.
162 */
328f5751 163 bool GetNextValue(wxString& strValueName, long& lIndex) const;
23324ae1
FM
164
165 /**
166 Returns @true if given subkey exists.
167 */
328f5751 168 bool HasSubKey(const wxChar* szKey) const;
23324ae1
FM
169
170 /**
171 Returns @true if any subkeys exist.
172 */
328f5751 173 bool HasSubKeys() const;
23324ae1
FM
174
175 /**
176 Returns @true if the value exists.
177 */
328f5751 178 bool HasValue(const wxChar* szValue) const;
23324ae1
FM
179
180 /**
181 Returns @true if any values exist.
182 */
328f5751 183 bool HasValues() const;
23324ae1
FM
184
185 /**
186 Returns @true if this key is empty, nothing under this key.
187 */
328f5751 188 bool IsEmpty() const;
23324ae1
FM
189
190 /**
191 Returns @true if the key is opened.
192 */
328f5751 193 bool IsOpened() const;
23324ae1
FM
194
195 /**
196 Explicitly opens the key. This method also allows the key to be opened in
bbc5b7f8
BP
197 read-only mode by passing wxRegKey::Read instead of default
198 wxRegKey::Write parameter.
23324ae1
FM
199 */
200 bool Open(AccessMode mode = Write);
201
23324ae1 202 /**
bbc5b7f8 203 Retrieves the string value.
23324ae1 204 */
328f5751 205 bool QueryValue(const wxChar* szValue, wxString& strValue) const;
bbc5b7f8
BP
206
207 /**
208 Retrieves the numeric value.
209 */
328f5751 210 const bool QueryValue(const wxChar* szValue, long* plValue) const;
23324ae1
FM
211
212 /**
213 Renames the key.
214 */
4cc4bfaf 215 bool Rename(const wxChar* szNewName);
23324ae1
FM
216
217 /**
218 Renames a value.
219 */
4cc4bfaf
FM
220 bool RenameValue(const wxChar* szValueOld,
221 const wxChar* szValueNew);
23324ae1 222
23324ae1 223 /**
bbc5b7f8
BP
224 Sets the given @a szValue which must be numeric.
225 If the value doesn't exist, it is created.
23324ae1 226 */
4cc4bfaf 227 bool SetValue(const wxChar* szValue, long lValue);
bbc5b7f8
BP
228 /**
229 Sets the given @a szValue which must be string.
230 If the value doesn't exist, it is created.
231 */
232 bool SetValue(const wxChar* szValue, const wxString& strValue);
233 /**
234 Sets the given @a szValue which must be binary.
235 If the value doesn't exist, it is created.
236 */
237 bool SetValue(const wxChar* szValue, const wxMemoryBuffer& buf);
23324ae1 238};