X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a90280fe1ac7b78563d44afffd1d3b0b521b5cd6..7344108e8a129a3f9b4df5ab0f98a1713db03b89:/interface/wx/msw/registry.h diff --git a/interface/wx/msw/registry.h b/interface/wx/msw/registry.h index d1c83ff48e..d3447ea75e 100644 --- a/interface/wx/msw/registry.h +++ b/interface/wx/msw/registry.h @@ -3,7 +3,7 @@ // Purpose: interface of wxRegKey // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /** @@ -32,58 +32,64 @@ @onlyfor{wxmsw} - @library{wxbase} - @category{misc} - @b Example: @code - wxRegKey *key = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey"); + // This assume that the key already exists, use HasSubKey() to check + // for the key existence if necessary. + wxRegKey key(wxRegKey::HKLM, "Software\\MyKey"); - // Create the key if it does not exist. - if( !key->Exists() ) - key->Create(); - - // Create a new value "MYVALUE" and set it to 12. - key->SetValue("MYVALUE", 12); + // Create a new value "MyValue" and set it to 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 + + + @library{wxbase} + @category{cfg} */ class wxRegKey { public: /** Default constructor, initializes to @c HKEY_CLASSES_ROOT. + + The @a viewMode parameter is new since wxWidgets 2.9.2. */ - wxRegKey(); + wxRegKey(WOW64ViewMode viewMode = WOW64ViewMode_Default); /** The constructor to set the full name of the key. + + The @a viewMode parameter is new since wxWidgets 2.9.2. */ - wxRegKey(const wxString& strKey); + wxRegKey(const wxString& strKey, + WOW64ViewMode viewMode = WOW64ViewMode_Default); /** - The constructor to set the full name of the key using one of the + The constructor to set the full name of the key using one of the standard keys, that is, HKCR, HKCU, HKLM, HKUSR, HKPD, HKCC or HKDD. + The @a viewMode parameter is new since wxWidgets 2.9.2. */ - wxRegKey(StdKey keyParent, const wxString& strKey); + wxRegKey(StdKey keyParent, const wxString& strKey, + WOW64ViewMode viewMode = WOW64ViewMode_Default); /** - The constructor to set the full name of the key under a previously created - parent. + The constructor to set the full name of the key under a previously + created parent. The registry view is inherited from the parent. */ wxRegKey(const wxRegKey& keyParent, const wxString& strKey); @@ -96,7 +102,7 @@ public: Write ///< Read and Write }; - /** + /** The standard registry key enumerator. */ enum StdKey @@ -128,7 +134,34 @@ public: Type_Multi_String, ///< Multiple Unicode strings Type_Resource_list, ///< Resource list in the resource map Type_Full_resource_descriptor, ///< Resource list in the hardware description - Type_Resource_requirements_list ///< + Type_Resource_requirements_list ///< + }; + + /** + Used to determine how the registry will be viewed, either as + 32-bit or 64-bit. + + @since 2.9.2 + */ + enum WOW64ViewMode + { + /** + Uses 32-bit registry for 32-bit applications and + 64-bit registry for 64-bit ones. + */ + WOW64ViewMode_Default, + + /** + Can be used in 64-bit apps to access the 32-bit registry, + has no effect (i.e. treated as default) in 32-bit apps. + */ + WOW64ViewMode_32, + + /** + Can be used in 32-bit apps to access the 64-bit registry, + has no effect (i.e. treated as default) in 64-bit apps. + */ + WOW64ViewMode_64 }; /** @@ -146,12 +179,12 @@ public: using the key. Returns @true if successful. */ bool Copy(wxRegKey& keyDst); - + /** Copy the value to another key, possibly changing its name. By default it will remain the same. Returns @true if successful. */ - bool CopyValue(const wxString& szValue, wxRegKey& keyDst, + bool CopyValue(const wxString& szValue, wxRegKey& keyDst, const wxString& szNewName = wxEmptyString); /** Creates the key. Will fail if the key already exists and @a bOkIfExists @@ -170,7 +203,7 @@ public: void DeleteSelf(); /** - Deletes the named value or use an empty string argument to remove the + Deletes the named value or use an empty string argument to remove the default value of the key. */ void DeleteValue(const wxString& szKey); @@ -192,7 +225,7 @@ public: Returns @true if successful. */ bool Export(wxOutputStream& ostr) const; - + /** Gets the first key. Returns @true if successful. */ @@ -223,6 +256,15 @@ public: */ wxString GetName(bool bShortPrefix = true) const; + /** + Retrieves the registry view used by this key. + + @since 2.9.2 + + @return The registry view given at the object's construction. + */ + WOW64ViewMode GetView() const { return m_viewMode; } + /** Gets the next key. Returns @true if successful. */ @@ -237,7 +279,7 @@ public: Gets the value type. */ ValueType GetValueType(const wxString& szValue) const; - + /** Returns @true if given subkey exists. */ @@ -246,7 +288,7 @@ public: /** Returns @true if any subkeys exist. */ - bool HasSubKeys() const; + bool HasSubkeys() const; /** Returns @true if the value exists. @@ -292,21 +334,25 @@ public: /** Retrieves the raw string value. Returns @true if successful. + An empty @a szValue queries the default/unnamed key value. */ bool QueryRawValue(const wxString& szValue, wxString& strValue) const; /** Retrieves the raw or expanded string value. Returns @true if successful. + An empty @a szValue queries the default/unnamed key value. */ bool QueryValue(const wxString& szValue, wxString& strValue, bool raw) const; /** Retrieves the numeric value. Returns @true if successful. + An empty @a szValue queries the default/unnamed key value. */ bool QueryValue(const wxString& szValue, long* plValue) const; /** Retrieves the binary structure. Returns @true if successful. + An empty @a szValue queries the default/unnamed key value. */ bool QueryValue(const wxString& szValue, wxMemoryBuffer& buf) const; @@ -324,13 +370,13 @@ public: /** Preallocate some memory for the name. For wxRegConfig usage only. */ - void ReserveMemoryForName(size_t bytes); + void ReserveMemoryForName(size_t bytes); /** Set or change the HKEY handle. */ void SetHkey(WXHKEY hKey); - + /** Set the full key name. The name is absolute. It should start with HKEY_xxx. @@ -344,20 +390,23 @@ public: Set the name relative to the parent key */ void SetName(const wxRegKey& keyParent, const wxString& strKey); - + /** Sets the given @a szValue which must be numeric. If the value doesn't exist, it is created. Returns @true if successful. + An empty @a szValue sets the default/unnamed key value. */ bool SetValue(const wxString& szValue, long lValue); /** Sets the given @a szValue which must be string. If the value doesn't exist, it is created. Returns @true if successful. + An empty @a szValue sets the default/unnamed key value. */ bool SetValue(const wxString& szValue, const wxString& strValue); /** - Sets the given @a szValue which must be binary. If the value doesn't + Sets the given @a szValue which must be binary. If the value doesn't exist, it is created. Returns @true if successful. + An empty @a szValue sets the default/unnamed key value. */ bool SetValue(const wxString& szValue, const wxMemoryBuffer& buf); };