#include <winstl/registry/reg_key.hpp>
This class acts as the value type of classes that manipulate registry keys and encapsulates the concept of a registry key.
C | The character type | |
T | The traits type. On translators that support default template arguments this defaults to reg_traits<C> | |
A | The allocator type. On translators that support default template arguments this defaults to processheap_allocator<C> |
Member Types | |
typedef C | char_type |
The character type. | |
typedef T | traits_type |
The traits type. | |
typedef A | allocator_type |
The allocator type. | |
typedef basic_reg_key< C, T, A > | class_type |
The current parameterisation of the type. | |
typedef traits_type::size_type | size_type |
The size type. | |
typedef traits_type::string_type | string_type |
The string type. | |
typedef traits_type::hkey_type | hkey_type |
The key type. | |
typedef bool | bool_type |
The Boolean type. | |
typedef basic_reg_value< C, T, A > | key_value_type |
The type of the key's values. | |
typedef hkey_type | resource_type |
Construction | |
basic_reg_key () | |
Default constructor. | |
basic_reg_key (hkey_type hkeyParent, char_type const *keyName, REGSAM accessMask=KEY_ALL_ACCESS) | |
Construct from the named sub-key of the given parent. | |
template<typename S> | |
basic_reg_key (hkey_type hkeyParent, S const &keyName, REGSAM accessMask=KEY_ALL_ACCESS) | |
Construct from the named sub-key of the given parent. | |
basic_reg_key (class_type const &keyParent, char_type const *keyName, REGSAM accessMask=KEY_ALL_ACCESS) | |
Construct from the named sub-key of the given parent. | |
template<typename S> | |
basic_reg_key (class_type const &keyParent, S const &keyName, REGSAM accessMask=KEY_ALL_ACCESS) | |
Construct from the named sub-key of the given parent. | |
basic_reg_key (class_type const &rhs) | |
Constructs an instance as a (logical) copy of another. | |
basic_reg_key (class_type const &rhs, REGSAM accessMask) | |
Constructs an instance as a (logical) copy of another, but with different permissions. | |
~basic_reg_key () throw () | |
Destructor. | |
class_type & | operator= (class_type const &rhs) |
Copy assignment operator. | |
Sub-key operations | |
class_type | open_sub_key (char_type const *subKeyName, REGSAM accessMask=KEY_ALL_ACCESS) |
Opens the named sub-key of this key. | |
template<typename S> | |
class_type | open_sub_key (S const &subKeyName, REGSAM accessMask=KEY_ALL_ACCESS) |
class_type | create_sub_key (char_type const *subKeyName, REGSAM accessMask=KEY_ALL_ACCESS) |
Creates a named sub-key of this key. | |
template<typename S> | |
class_type | create_sub_key (S const &subKeyName, REGSAM accessMask=KEY_ALL_ACCESS) |
Creates a named sub-key of this key. | |
bool_type | delete_sub_key (char_type const *subKeyName) |
Deletes the named sub-key of this key. | |
template<typename S> | |
class_type | delete_sub_key (S const &subKeyName) |
Deletes the named sub-key of this key. | |
static class_type | create_key (HKEY hkey, char_type const *subKeyName, REGSAM accessMask=KEY_ALL_ACCESS) |
Creates a named sub-key of a given key. | |
template<typename H, typename S> | |
static class_type | create_key (H const &key, S const &subKeyName, REGSAM accessMask=KEY_ALL_ACCESS) |
Creates a named sub-key of this key. | |
Public Member Functions | |
hkey_type | dup_key_handle (REGSAM accessMask=KEY_ALL_ACCESS, result_type *res=NULL) |
Returns a duplicate of the key's handle, if any. | |
Attributes | |
string_type const & | name () const |
The name of the key. | |
string_type | reg_class () const |
The registry class of the key. | |
size_type | num_sub_keys () const |
The number of sub-keys. | |
size_type | num_values () const |
The number of values. | |
template<typename S> | |
bool_type | has_sub_key (S const &subKeyName) |
Indicates whether the sub-key exists. | |
template<typename S> | |
bool_type | has_value (S const &valueName) |
Indicates whether the value exists. | |
hkey_type | get_key_handle () const |
The handle to the underlying Registry API key. | |
hkey_type | get () const |
The handle to the underlying Registry API key. | |
REGSAM | get_access_mask () const |
The access mask associated with the key. | |
Value operations | |
bool_type | set_value (char_type const *valueName, DWORD value) |
Sets the named value to the value of the given 32-bit integer. | |
bool_type | set_value (char_type const *valueName, char_type const *value, ws_uint_t type=REG_SZ) |
Sets the named value to the value of the given string. | |
bool_type | set_value (char_type const *valueName, char_type const **values, size_type numValues) |
Sets the named value to the values of the given string array. | |
bool_type | set_value (char_type const *valueName, void const *value, size_type cbValue) |
Sets the named value to the given binary value. | |
template<typename S> | |
bool_type | set_value (S const &valueName, DWORD value) |
Sets the named value to the value of the given 32-bit integer. | |
template<typename S> | |
bool_type | set_value (S const &valueName, char_type const *value, ws_uint_t type=REG_SZ) |
Sets the named value to the value of the given string. | |
template<typename S> | |
bool_type | set_value (S const &valueName, char_type const **values, size_type numValues) |
Sets the named value to the values of the given string array. | |
template<typename S> | |
bool_type | set_value (S const &valueName, void const *value, size_type cbValue) |
Sets the named value to the given binary value. | |
bool_type | set_value (char_type const *valueName, int value) |
Sets the named value to the given integer (stored as an unsigned value). | |
template<typename S> | |
bool_type | set_value (S const &valueName, int value) |
Sets the named value to the given integer (stored as an unsigned value). | |
bool_type | delete_value (char_type const *valueName) |
Deletes the named value. | |
template<typename S> | |
bool_type | delete_value (S const &valueName) |
Deletes the named value. | |
key_value_type | get_value (char_type const *valueName) const |
Returns the named value. | |
template<typename S> | |
key_value_type | get_value (S const &valueName) const |
Returns the named value. | |
Operations | |
void | swap (class_type &rhs) throw () |
Efficiently swaps the contents between two instances / /. |
typedef C char_type |
The character type.
typedef T traits_type |
The traits type.
typedef A allocator_type |
The allocator type.
typedef basic_reg_key<C, T, A> class_type |
The current parameterisation of the type.
typedef traits_type::size_type size_type |
The size type.
typedef traits_type::string_type string_type |
The string type.
typedef traits_type::hkey_type hkey_type |
The key type.
typedef bool bool_type |
The Boolean type.
typedef basic_reg_value<C, T, A> key_value_type |
The type of the key's values.
basic_reg_key | ( | ) |
Default constructor.
basic_reg_key | ( | hkey_type | hkeyParent, | |
char_type const * | keyName, | |||
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) | [inline] |
Construct from the named sub-key of the given parent.
hkeyParent | A handle to the parent key, whose named subkey is to be opened. | |
keyName | The name of the subkey to open. If NULL or the empty string, then a copy of hkeyParent will be opened. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be opened. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
basic_reg_key | ( | hkey_type | hkeyParent, | |
S const & | keyName, | |||
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) | [inline] |
Construct from the named sub-key of the given parent.
hkeyParent | A handle to the parent key, whose named subkey is to be opened. | |
keyName | The name of the subkey to open. If NULL or the empty string, then a copy of hkeyParent will be opened. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be opened. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
basic_reg_key | ( | class_type const & | keyParent, | |
char_type const * | keyName, | |||
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) | [inline] |
Construct from the named sub-key of the given parent.
keyParent | A handle to the parent key, whose named subkey is to be opened. | |
keyName | The name of the subkey to open. If NULL or the empty string, then a copy of keyParent will be opened. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be opened. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
basic_reg_key | ( | class_type const & | keyParent, | |
S const & | keyName, | |||
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) | [inline] |
Construct from the named sub-key of the given parent.
keyParent | A handle to the parent key, whose named subkey is to be opened. | |
keyName | The name of the subkey to open. If NULL or the empty string, then a copy of keyParent will be opened. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be opened. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
basic_reg_key | ( | class_type const & | rhs | ) |
Constructs an instance as a (logical) copy of another.
rhs | Instance whose key will be opened by the new instance. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be opened. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
basic_reg_key | ( | class_type const & | rhs, | |
REGSAM | accessMask | |||
) |
Constructs an instance as a (logical) copy of another, but with different permissions.
rhs | Instance whose key will be opened by the new instance. | |
accessMask | The permissions for the new instance. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be opened. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
~basic_reg_key | ( | ) | throw () |
Destructor.
Releases any resources allocated by the instance, including closing the underlying registry key.
class_type& operator= | ( | class_type const & | rhs | ) |
Copy assignment operator.
string_type const& name | ( | ) | const |
The name of the key.
string_type reg_class | ( | ) | const |
The registry class of the key.
size_type num_sub_keys | ( | ) | const |
The number of sub-keys.
size_type num_values | ( | ) | const |
The number of values.
bool_type has_sub_key | ( | S const & | subKeyName | ) | [inline] |
Indicates whether the sub-key exists.
subKeyName | The name of the sub-key to test |
References stlsoft_ns_qual.
bool_type has_value | ( | S const & | valueName | ) | [inline] |
Indicates whether the value exists.
valueName | The name of the value to test |
References stlsoft_ns_qual.
hkey_type get_key_handle | ( | ) | const |
The handle to the underlying Registry API key.
NULL
in the case where an instance constructor failed to open the key with the requested permissions. Referenced by winstl::get_handle(), and winstl::get_HKEY().
hkey_type get | ( | ) | const |
REGSAM get_access_mask | ( | ) | const |
The access mask associated with the key.
class_type open_sub_key | ( | char_type const * | subKeyName, | |
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) |
Opens the named sub-key of this key.
class_type create_sub_key | ( | char_type const * | subKeyName, | |
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) |
Creates a named sub-key of this key.
subKeyName | Name of the subkey to created. If NULL or the empty string, then the function returns a copy of the callee. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be created. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
class_type create_sub_key | ( | S const & | subKeyName, | |
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) | [inline] |
Creates a named sub-key of this key.
subKeyName | Name of the subkey to created. If NULL or the empty string, then the function returns a copy of the callee. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be created. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
References stlsoft_ns_qual.
static class_type create_key | ( | HKEY | hkey, | |
char_type const * | subKeyName, | |||
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) | [static] |
Creates a named sub-key of a given key.
hkey | The parent registry key. | |
subKeyName | Name of the subkey to created. If NULL or the empty string, then the function returns a copy of the callee. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be created. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
static class_type create_key | ( | H const & | key, | |
S const & | subKeyName, | |||
REGSAM | accessMask = KEY_ALL_ACCESS | |||
) | [inline, static] |
Creates a named sub-key of this key.
key | The parent registry key. | |
subKeyName | Name of the subkey to created. If NULL or the empty string, then the function returns a copy of the callee. | |
accessMask | A mask of KEY_* flags that define the required access to the key. Defaults to KEY_ALL_ACCESS. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown indicating why the given key could not be created. If not, then the instance constructed will be empty, as denoted by a NULL value returned from the get_key_handle() method. |
References winstl::get_HKEY(), and stlsoft_ns_qual.
Deletes the named sub-key of this key.
subKeyName | The name of the sub-key to be deleted. |
true | The sub-key existed and was successfully deleted. | |
false | The sub-key does not exist. (Note: if exception handling is not enabled, then false will also be returned for any other reason, and the reason will be available via GetLastError() .) |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the sub-key exists but cannot be deleted. |
class_type delete_sub_key | ( | S const & | subKeyName | ) | [inline] |
Deletes the named sub-key of this key.
subKeyName | The name of the sub-key to be deleted. |
true | The sub-key existed and was successfully deleted. | |
false | The sub-key does not exist. (Note: if exception handling is not enabled, then false will also be returned for any other reason, and the reason will be available via GetLastError() .) |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the sub-key exists but cannot be deleted. |
References stlsoft_ns_qual.
hkey_type dup_key_handle | ( | REGSAM | accessMask = KEY_ALL_ACCESS , |
|
result_type * | res = NULL | |||
) |
Returns a duplicate of the key's handle, if any.
accessMask | The access mask for the | |
res | A pointer to a variable (of type result_type) into which will be written the result of the underlying registry API call. |
Sets the named value to the value of the given 32-bit integer.
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
bool_type set_value | ( | char_type const * | valueName, | |
char_type const * | value, | |||
ws_uint_t | type = REG_SZ | |||
) |
Sets the named value to the value of the given string.
/ /
valueName | The name of the value. / | |
value | The value of the value / | |
type | The type of the value. Must be one of REG_SZ, REG_EXPAND_SZ or REG_MULTI_SZ. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
Sets the named value to the values of the given string array.
/ /
valueName | The name of the value. / | |
values | The string array. / | |
numValues | Number of elements in the string array. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
Sets the named value to the given binary value.
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
bool_type set_value | ( | S const & | valueName, | |
DWORD | value | |||
) | [inline] |
Sets the named value to the value of the given 32-bit integer.
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
References stlsoft_ns_qual.
bool_type set_value | ( | S const & | valueName, | |
char_type const * | value, | |||
ws_uint_t | type = REG_SZ | |||
) | [inline] |
Sets the named value to the value of the given string.
/ /
valueName | The name of the value. / | |
value | The value of the value / | |
type | The type of the value. Must be one of REG_SZ, REG_EXPAND_SZ or REG_MULTI_SZ. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
References stlsoft_ns_qual.
bool_type set_value | ( | S const & | valueName, | |
char_type const ** | values, | |||
size_type | numValues | |||
) | [inline] |
Sets the named value to the values of the given string array.
/ /
valueName | The name of the value. / | |
values | The string array. / | |
numValues | Number of elements in the string array. |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
References stlsoft_ns_qual.
Sets the named value to the given binary value.
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
References stlsoft_ns_qual.
Sets the named value to the given integer (stored as an unsigned value).
/ /
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
bool_type set_value | ( | S const & | valueName, | |
int | value | |||
) | [inline] |
Sets the named value to the given integer (stored as an unsigned value).
/ /
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value cannot be set. |
References stlsoft_ns_qual.
Deletes the named value.
valueName | The name of the value to be deleted. |
true | The value existed and was successfully deleted. | |
false | The value does not exist. (Note: if exception handling is not enabled, then false will also be returned for any other reason, and the reason will be available via GetLastError() .) |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value exists but cannot be deleted. |
bool_type delete_value | ( | S const & | valueName | ) | [inline] |
Deletes the named value.
valueName | The name of the value to be deleted. |
true | The value existed and was successfully deleted. | |
false | The value does not exist. (Note: if exception handling is not enabled, then false will also be returned for any other reason, and the reason will be available via GetLastError() .) |
winstl::registry_exception | If exception handling is enabled, an instance of registry_exception will be thrown if the value exists but cannot be deleted. |
References stlsoft_ns_qual.
key_value_type get_value | ( | char_type const * | valueName | ) | const |
key_value_type get_value | ( | S const & | valueName | ) | const [inline] |
void swap | ( | class_type & | rhs | ) | throw () |
Efficiently swaps the contents between two instances / /.
rhs | The parameter whose contents will be swapped. |