libfilezilla
Loading...
Searching...
No Matches
registry.hpp
Go to the documentation of this file.
1#ifndef LIBFILEZILLA_GLUE_REGISTRY_HEADER
2#define LIBFILEZILLA_GLUE_REGISTRY_HEADER
3
8#include "../libfilezilla.hpp"
9
10#ifdef FZ_WINDOWS
11
12#include "windows.hpp"
13
14#include <optional>
15#include <string>
16
17namespace fz {
18
26{
27public:
28 regkey() = default;
29 ~regkey();
30
31 enum regview {
32 regview_native,
33 regview_32,
34 regview_64
35 };
36
37
39 explicit regkey(HKEY const root, std::wstring const& subkey, bool readonly, regview v = regview_native);
40
41 regkey(regkey const&) = delete;
42 regkey& operator=(regkey const&) = delete;
43
44 void close();
45
51 bool open(HKEY const root, std::wstring const& subkey, bool readonly, regview v = regview_native);
52
53 bool has_value(std::wstring const& name) const;
54
56 std::wstring value(std::wstring const& name) const;
57
59 uint64_t int_value(std::wstring const& name) const;
60
61 bool set_value(std::wstring const& name, std::wstring const& value);
62 bool set_value(std::wstring const& name, uint64_t value);
63
64 explicit operator bool() const {
65 return key_.has_value();
66 }
67
68 bool delete_value(std::wstring const& name);
69
70private:
71 mutable std::optional<HKEY> key_;
72};
73}
74
75#else
76#error This file is for Windows only
77#endif
78
79#endif
Prepresents a key in the Windows registry.
Definition registry.hpp:26
regkey(HKEY const root, std::wstring const &subkey, bool readonly, regview v=regview_native)
See.
uint64_t int_value(std::wstring const &name) const
Gets the value with the given name as integer, converting if necessary.
bool open(HKEY const root, std::wstring const &subkey, bool readonly, regview v=regview_native)
Opens the specified registry key.
std::wstring value(std::wstring const &name) const
Gets the value with the given name as wstring, converting if necessary.
Sets some global macros and further includes string.hpp.
The namespace used by libfilezilla.
Definition apply.hpp:17
bool dispatch(event_base const &ev, F &&f)
Dispatch for simple_event<> based events to simple functors.
Definition event_handler.hpp:199