From: Vadim Zeitlin Date: Wed, 16 Feb 2011 23:51:08 +0000 (+0000) Subject: Correct example of wxRegKey use in its documentation. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/03c9cce5642dc6af13f7ab55639cb905e83e4412?ds=inline Correct example of wxRegKey use in its documentation. Don't check for the key existence, it ought to exist if we create it like this. Also don't allocate wxRegKey object on the heap unnecessarily. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66932 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/interface/wx/msw/registry.h b/interface/wx/msw/registry.h index db873eb93d..67a8658f5f 100644 --- a/interface/wx/msw/registry.h +++ b/interface/wx/msw/registry.h @@ -35,30 +35,28 @@ @b Example: @code - wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey"); - - // Create the key if it does not exist. - if( !key->Exists() ) - key->Create(); + // This assume that the key already exists, use HasSubKey() to check + // for the key existence if necessary. + wxRegKey key(wxRegKey::HKLM, "Software\\MyKey"); // Create a new value "MYVALUE" and set it to 12. - key->SetValue("MYVALUE", 12); + key.SetValue("MyValue", 12); // Read the value back. long value; - key->QueryValue("MYVALUE", &value); + key.QueryValue("MyValue", &value); wxMessageBox(wxString::Format("%d", value), "Registry Value", wxOK); // Get the number of subkeys and enumerate them. size_t subkeys; - key->GetKeyInfo(&subkeys, NULL, NULL, NULL); + key.GetKeyInfo(&subkeys, NULL, NULL, NULL); wxString key_name; - key->GetFirstKey(key_name, 1); + key.GetFirstKey(key_name, 1); for(int i = 0; i < subkeys; i++) { wxMessageBox(key_name, "Subkey Name", wxOK); - key->GetNextKey(key_name, 1); + key.GetNextKey(key_name, 1); } @endcode