wxRegKey is a class representing the Windows registry. One can create, query and delete registry keys using this class.
The Windows registry is easy to understand. There are five registry keys, namely:
After creating a key, it can hold a value. The values can be:
Derived from
None
Include files
<wx/config.h>
Example
wxRegKey *pRegKey = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey"); //will create the Key if it does not exist if( !pRegKey->Exists() ) pRegKey->Create(); //will create a new value MYVALUE and set it to 12 pRegKey->SetValue("MYVALUE",12); //Query for the Value and Retrieve it long lMyVal; wxString strTemp; pRegKey->QueryValue("MYVALUE",&lMyVal); strTemp.Printf("%d",lMyVal); wxMessageBox(strTemp,"Registry Value",0,this); //Retrive the number of SubKeys and enumerate them size_t nSubKeys; pRegKey->GetKeyInfo(&nSubKeys,NULL,NULL,NULL); pRegKey->GetFirstKey(strTemp,1); for(int i=0;i<nSubKeys;i++) { wxMessageBox(strTemp,"SubKey Name",0,this); pRegKey->GetNextKey(strTemp,1); }
The Constructor to set to HKCR
The constructor to set the full name of the key.
The constructor to set the full name of the key under a previously created parent.
Closes the key.
Creates the key. Will fail if the key already exists and bOkIfExists is false.
Deletes this key and all of its subkeys and values recursively.
Deletes the subkey with all of its subkeys/values recursively.
Deletes the named value.
static bool Exists(void) const
Returns true if the key exists.
wxString GetName(bool bShortPrefix = true) const
Gets the name of the registry key.
Gets the first key.
Gets the first value of this key.
bool Exists(size_t * pnSubKeys, size_t * pnValues, size_t * pnMaxValueLen) const
Gets information about the key.
Parameters
bool GetNextKey(wxString& strKeyName, long& lIndex) const
Gets the next key.
bool GetNextValue(wxString& strValueName, long& lIndex) const
Gets the next key value for this key.
bool HasValue(const wxChar * szValue) const
Returns true if the value exists.
Returns true if any values exist.
bool HasSubKey(const wxChar * szKey) const
Returns true if given subkey exists.
Returns true if any subkeys exist.
Returns true if this key is empty, nothing under this key.
Returns true if the key is opened.
Explicitly opens the key to be opened.
bool QueryValue(const wxChar * szValue, wxString& strValue) const
Retrieves the string value.
bool QueryValue(const wxChar * szValue, long * plValue) const
Retrieves the numeric value.
Renames the key.
Renames a value.
Sets the numeric value.
ymasuda 平成17年11月19日