]>
git.saurik.com Git - wxWidgets.git/blob - interface/msw/registry.h
dfb7835f13419eb17a89f8e21849536c8b41d379
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/registry.h
3 // Purpose: interface of wxRegKey
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @wxheader{msw/registry.h}
13 wxRegKey is a class representing the Windows registry (it is only available
14 under Windows). One can create, query and delete registry keys using this
17 The Windows registry is easy to understand. There are five registry keys,
20 @li HKEY_CLASSES_ROOT (HKCR)
21 @li HKEY_CURRENT_USER (HKCU)
22 @li HKEY_LOCAL_MACHINE (HKLM)
23 @li HKEY_CURRENT_CONFIG (HKCC)
26 After creating a key, it can hold a value. The values can be:
31 @li Multi String Value
32 @li Expandable String Value
42 wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey");
44 // Create the key if it does not exist.
48 // Create a new value "MYVALUE" and set it to 12.
49 key->SetValue("MYVALUE", 12);
51 // Read the value back.
53 key->QueryValue("MYVALUE", &value);
54 wxMessageBox(wxString::Format("%d", value), "Registry Value", wxOK);
56 // Get the number of subkeys and enumerate them.
58 key->GetKeyInfo(&subkeys, NULL, NULL, NULL);
61 key->GetFirstKey(key_name, 1);
62 for(int i = 0; i < subkeys; i++)
64 wxMessageBox(key_name, "Subkey Name", wxOK);
65 key->GetNextKey(key_name, 1);
73 Default constructor, initializes to HKCR.
77 The constructor to set the full name of the key.
79 wxRegKey(const wxString
& strKey
);
81 The constructor to set the full name of the key under a previously created
84 wxRegKey(const wxRegKey
& keyParent
, const wxString
& strKey
);
87 Access modes for wxRegKey.
92 Write
///< Read and Write
101 Creates the key. Will fail if the key already exists and @a bOkIfExists is
104 bool Create(bool bOkIfExists
= true);
107 Deletes the subkey with all of its subkeys/values recursively.
109 void DeleteKey(const wxChar
* szKey
);
112 Deletes this key and all of its subkeys and values recursively.
117 Deletes the named value.
119 void DeleteValue(const wxChar
* szKey
);
122 Returns @true if the key exists.
129 bool GetFirstKey(wxString
& strKeyName
, long& lIndex
);
132 Gets the first value of this key.
134 bool GetFirstValue(wxString
& strValueName
, long& lIndex
);
137 Gets information about the key.
140 The number of subkeys.
142 The maximum length of the subkey name.
144 The number of values.
146 The maximum length of a value.
148 bool GetKeyInfo(size_t* pnSubKeys
, size_t* pnMaxKeyLen
,
149 size_t* pnValues
, size_t* pnMaxValueLen
) const;
152 Gets the name of the registry key.
154 wxString
GetName(bool bShortPrefix
= true) const;
159 bool GetNextKey(wxString
& strKeyName
, long& lIndex
) const;
162 Gets the next key value for this key.
164 bool GetNextValue(wxString
& strValueName
, long& lIndex
) const;
167 Returns @true if given subkey exists.
169 bool HasSubKey(const wxChar
* szKey
) const;
172 Returns @true if any subkeys exist.
174 bool HasSubKeys() const;
177 Returns @true if the value exists.
179 bool HasValue(const wxChar
* szValue
) const;
182 Returns @true if any values exist.
184 bool HasValues() const;
187 Returns @true if this key is empty, nothing under this key.
189 bool IsEmpty() const;
192 Returns @true if the key is opened.
194 bool IsOpened() const;
197 Explicitly opens the key. This method also allows the key to be opened in
198 read-only mode by passing wxRegKey::Read instead of default
199 wxRegKey::Write parameter.
201 bool Open(AccessMode mode
= Write
);
204 Retrieves the string value.
206 bool QueryValue(const wxChar
* szValue
, wxString
& strValue
) const;
209 Retrieves the numeric value.
211 const bool QueryValue(const wxChar
* szValue
, long* plValue
) const;
216 bool Rename(const wxChar
* szNewName
);
221 bool RenameValue(const wxChar
* szValueOld
,
222 const wxChar
* szValueNew
);
225 Sets the given @a szValue which must be numeric.
226 If the value doesn't exist, it is created.
228 bool SetValue(const wxChar
* szValue
, long lValue
);
230 Sets the given @a szValue which must be string.
231 If the value doesn't exist, it is created.
233 bool SetValue(const wxChar
* szValue
, const wxString
& strValue
);
235 Sets the given @a szValue which must be binary.
236 If the value doesn't exist, it is created.
238 bool SetValue(const wxChar
* szValue
, const wxMemoryBuffer
& buf
);