]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/msw/registry.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/registry.h
3 // Purpose: interface of wxRegKey
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
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
16 The Windows registry is easy to understand. There are five registry keys,
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)
25 After creating a key, it can hold a value. The values can be:
30 @li Multi String Value
31 @li Expandable String Value
41 wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey");
43 // Create the key if it does not exist.
47 // Create a new value "MYVALUE" and set it to 12.
48 key->SetValue("MYVALUE", 12);
50 // Read the value back.
52 key->QueryValue("MYVALUE", &value);
53 wxMessageBox(wxString::Format("%d", value), "Registry Value", wxOK);
55 // Get the number of subkeys and enumerate them.
57 key->GetKeyInfo(&subkeys, NULL, NULL, NULL);
60 key->GetFirstKey(key_name, 1);
61 for(int i = 0; i < subkeys; i++)
63 wxMessageBox(key_name, "Subkey Name", wxOK);
64 key->GetNextKey(key_name, 1);
72 Default constructor, initializes to @c HKEY_CLASSES_ROOT.
76 The constructor to set the full name of the key.
78 wxRegKey(const wxString
& strKey
);
80 The constructor to set the full name of the key under a previously created
83 wxRegKey(const wxRegKey
& keyParent
, const wxString
& strKey
);
86 Access modes for wxRegKey.
91 Write
///< Read and Write
100 Creates the key. Will fail if the key already exists and @a bOkIfExists is
103 bool Create(bool bOkIfExists
= true);
106 Deletes the subkey with all of its subkeys/values recursively.
108 void DeleteKey(const wxString
& szKey
);
111 Deletes this key and all of its subkeys and values recursively.
116 Deletes the named value.
118 void DeleteValue(const wxString
& szKey
);
121 Returns @true if the key exists.
128 bool GetFirstKey(wxString
& strKeyName
, long& lIndex
);
131 Gets the first value of this key.
133 bool GetFirstValue(wxString
& strValueName
, long& lIndex
);
136 Gets information about the key.
139 The number of subkeys.
141 The maximum length of the subkey name.
143 The number of values.
145 The maximum length of a value.
147 bool GetKeyInfo(size_t* pnSubKeys
, size_t* pnMaxKeyLen
,
148 size_t* pnValues
, size_t* pnMaxValueLen
) const;
151 Gets the name of the registry key.
153 wxString
GetName(bool bShortPrefix
= true) const;
158 bool GetNextKey(wxString
& strKeyName
, long& lIndex
) const;
161 Gets the next key value for this key.
163 bool GetNextValue(wxString
& strValueName
, long& lIndex
) const;
166 Returns @true if given subkey exists.
168 bool HasSubKey(const wxString
& szKey
) const;
171 Returns @true if any subkeys exist.
173 bool HasSubKeys() const;
176 Returns @true if the value exists.
178 bool HasValue(const wxString
& szValue
) const;
181 Returns @true if any values exist.
183 bool HasValues() const;
186 Returns @true if this key is empty, nothing under this key.
188 bool IsEmpty() const;
191 Returns @true if the key is opened.
193 bool IsOpened() const;
196 Explicitly opens the key. This method also allows the key to be opened in
197 read-only mode by passing wxRegKey::Read instead of default
198 wxRegKey::Write parameter.
200 bool Open(AccessMode mode
= Write
);
203 Retrieves the string value.
205 bool QueryValue(const wxString
& szValue
, wxString
& strValue
) const;
208 Retrieves the numeric value.
210 const bool QueryValue(const wxString
& szValue
, long* plValue
) const;
215 bool Rename(const wxString
& szNewName
);
220 bool RenameValue(const wxString
& szValueOld
,
221 const wxString
& szValueNew
);
224 Sets the given @a szValue which must be numeric.
225 If the value doesn't exist, it is created.
227 bool SetValue(const wxString
& szValue
, long lValue
);
229 Sets the given @a szValue which must be string.
230 If the value doesn't exist, it is created.
232 bool SetValue(const wxString
& szValue
, const wxString
& strValue
);
234 Sets the given @a szValue which must be binary.
235 If the value doesn't exist, it is created.
237 bool SetValue(const wxString
& szValue
, const wxMemoryBuffer
& buf
);