|
xentara-utils v2.0.6
The Xentara Utility Library
|
A Windows registry key handle that closes itself on destruct. More...
#include <xentara/utils/windows/RegistryKey.hpp>
Inheritance diagram for xentara::utils::windows::RegistryKey:Classes | |
| class | Setter |
| Helper class for calling functions that take an output parameter. More... | |
| class | SubKeyEnumerator |
| An object that allows enumerating the sub keys of a key. More... | |
| class | ValueEnumerator |
| An object that allows enumerating the values contained within a key. More... | |
Public Types | |
| using | HKEY = HKEY__ * |
| A native Windows registry key handle. | |
| using | REGSAM = unsigned long |
| Access flags for registry keys. | |
| using | DWORD = unsigned long |
| Used for registry value types. | |
Public Member Functions | |
| constexpr | RegistryKey () noexcept=default |
| Default constructor. | |
| constexpr | RegistryKey (HKEY nativeHandle) noexcept |
| Conversion from a native registry key handle. | |
| constexpr | RegistryKey (RegistryKey &&other) noexcept |
| Move constructor. | |
| ~RegistryKey () | |
| Destructor. Silently closes the registry key. | |
| auto | operator= (RegistryKey &&rhs) noexcept -> RegistryKey & |
| Move assignment operator. | |
| constexpr | operator HKEY () const noexcept |
| Conversion to a native registry key handle. | |
| constexpr | operator bool () const noexcept |
| Checks whether the object contains a valid registry key. | |
| auto | operator= (HKEY nativeHandle) noexcept -> RegistryKey & |
| Assignment from a native registry key handle. | |
| template<RegistryValue Value> | |
| auto | value (DWORD flags=0) const -> eh::expected< Value, std::error_code > |
| Reads the default value. | |
| template<RegistryValue Value> | |
| auto | value (const wchar_t *name, DWORD flags=0) const -> eh::expected< Value, std::error_code > |
| Reads a named value. | |
| template<RegistryValue Value> | |
| auto | value (const wchar_t *subKey, const wchar_t *name, DWORD flags=0) const -> eh::expected< Value, std::error_code > |
| Reads a named value from a sub key. | |
| auto | subKey (const wchar_t *subKeyPath, REGSAM desiredAccess) const -> eh::expected< RegistryKey, std::error_code > |
| Gets a named sub key. | |
| auto | valueNames () const -> ValueEnumerator |
| Returns an enumerator that can be used to iterate over the names of all named values. | |
| auto | subKeyNames () const -> SubKeyEnumerator |
| Returns an enumerator that can be used to iterate over the names of all sub keys. | |
| constexpr auto | release () noexcept -> HKEY |
| Removes the registry key and passes ownership to the caller. | |
| auto | close () noexcept -> std::error_code |
| Closes the registry key, if it is open. | |
| auto | setter () noexcept -> Setter |
| Gets a setter for use as an output parameter for C functions. | |
Static Public Member Functions | |
| static auto | open (HKEY parent, const wchar_t *subKeyPath, REGSAM desiredAccess) -> eh::expected< RegistryKey, std::error_code > |
| Opens a registry key. | |
A Windows registry key handle that closes itself on destruct.
This class can be moved but not copied.
| using xentara::utils::windows::RegistryKey::DWORD = unsigned long |
Used for registry value types.
| using xentara::utils::windows::RegistryKey::HKEY = HKEY__* |
A native Windows registry key handle.
| using xentara::utils::windows::RegistryKey::REGSAM = unsigned long |
Access flags for registry keys.
|
constexprdefaultnoexcept |
Default constructor.
|
constexprnoexcept |
Conversion from a native registry key handle.
| nativeHandle | The native handle |
|
constexprnoexcept |
Move constructor.
Takes ownership of the other handle's value.
| other | The handle to move. Will be turned into a null handle. |
| xentara::utils::windows::RegistryKey::~RegistryKey | ( | ) |
Destructor. Silently closes the registry key.
|
noexcept |
Closes the registry key, if it is open.
|
static |
Opens a registry key.
| parent | The parent key |
| subKeyPath | The sub key path |
| desiredAccess | The desired access |
|
explicitconstexprnoexcept |
Checks whether the object contains a valid registry key.
|
constexprnoexcept |
Conversion to a native registry key handle.
|
noexcept |
Assignment from a native registry key handle.
Any existing handle is silently closed.
| nativeHandle | The native registry key handle |
|
noexcept |
Move assignment operator.
Takes ownership of the other handle's value. Any existing handle is silently closed.
| rhs | The handle to move. Will be turned into a null handle. |
|
constexprnoexcept |
Removes the registry key and passes ownership to the caller.
After this call, this object will no longer contain a registry key.
|
noexcept |
Gets a setter for use as an output parameter for C functions.
This function returns a helper object that can be passed to a function that takes a PHKEY as output parameter, like e.g. RegCreateKeyEx(). This provides a safe way of creating registry keys using such a function without running the risk of leaking the created key.
RegCreateKeyEx() can be called like this, for example:
| auto xentara::utils::windows::RegistryKey::subKey | ( | const wchar_t * | subKeyPath, |
| REGSAM | desiredAccess | ||
| ) | const -> eh::expected<RegistryKey, std::error_code> |
Gets a named sub key.
| subKeyPath | The sub key path |
| desiredAccess | The desired access |
| auto xentara::utils::windows::RegistryKey::subKeyNames | ( | ) | const -> SubKeyEnumerator |
Returns an enumerator that can be used to iterate over the names of all sub keys.
| auto xentara::utils::windows::RegistryKey::value | ( | const wchar_t * | name, |
| DWORD | flags = 0 |
||
| ) | const -> eh::expected<Value, std::error_code> |
Reads a named value.
| name | The name of the value. If you pass nullprt or an empty string, the default value will be read. |
| flags | The flags for reading the value. If you do not specify any type restriction flags, suitable flags are added automatically. |
| auto xentara::utils::windows::RegistryKey::value | ( | const wchar_t * | subKey, |
| const wchar_t * | name, | ||
| DWORD | flags = 0 |
||
| ) | const -> eh::expected< Value, std::error_code > |
Reads a named value from a sub key.
| subKey | The name of the sub key. If you pass nullprt or an empty string, the value will be read from the key directly. |
| name | The name of the value. If you pass nullprt or an empty string, the default value will be read. |
| flags | The flags for reading the value. If you do not specify any type restriction flags, suitable flags are added automatically. |
| auto xentara::utils::windows::RegistryKey::value | ( | DWORD | flags = 0 | ) | const -> eh::expected<Value, std::error_code> |
Reads the default value.
| flags | The flags for reading the value. If you do not specify any type restriction flags, suitable flags are added automatically. |
| auto xentara::utils::windows::RegistryKey::valueNames | ( | ) | const -> ValueEnumerator |
Returns an enumerator that can be used to iterate over the names of all named values.