LIBURANIA
GUI library (a wrapper of Win32 API) in C++
読み取り中…
検索中…
一致する文字列を見つけられません
registry.h
[詳解]
1/*
2 * Copyright 2004-2021 oZ/acy (名賀月晃嗣)
3 * Redistribution and use in source and binary forms,
4 * with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
39#ifndef INCLUDE_GUARD_URANIA_REGISTRY_H
40#define INCLUDE_GUARD_URANIA_REGISTRY_H
41
42// windows.hのmin/maxマクロの抑止
43#ifndef NOMINMAX
44#define NOMINMAX
45#endif
46
47#include <windows.h>
48#include <string>
49
50
51namespace urania {
52
60
61
66{
67private:
68 HKEY key_;
69
70protected:
71 RegistryBase() noexcept : key_(NULL) {}
72
73 void setKey_(HKEY k) noexcept { key_ = k; }
74 HKEY getKey_() const noexcept { return key_; }
75
76public:
78 {
79 if (key_)
80 ::RegCloseKey(key_);
81 }
82
83 explicit operator bool() const noexcept { return key_ != NULL; }
84 bool operator!() const noexcept { return !bool(*this); }
85
86protected:
87 static HKEY getRoot_(RegRootKey k);
88};
89
90
95{
96public:
97 RegistryReader(RegRootKey root, const std::wstring& path);
98
99 DWORD getDwordData(const std::wstring& name);
100 std::wstring getStringData(const std::wstring& name);
101};
102
103
108{
109public:
110 RegistryWriter(RegRootKey root, const std::wstring& path);
111
112 void setDwordData(const std::wstring& name, DWORD val);
113 void setStringData(const std::wstring& name, const std::wstring& val);
114};
115
116
117}// end of namespace urania
118
119
120
121
122#endif // INCLUDE_GUARD_URANIA_REGISTRY_H
レジストリ操作基底
Definition registry.h:66
RegistryBase() noexcept
Definition registry.h:71
~RegistryBase()
Definition registry.h:77
bool operator!() const noexcept
Definition registry.h:84
void setKey_(HKEY k) noexcept
Definition registry.h:73
HKEY getKey_() const noexcept
Definition registry.h:74
static HKEY getRoot_(RegRootKey k)
Definition registry.cpp:42
レジストリ讀込クラス
Definition registry.h:95
std::wstring getStringData(const std::wstring &name)
Definition regread.cpp:97
DWORD getDwordData(const std::wstring &name)
Definition regread.cpp:67
RegistryReader(RegRootKey root, const std::wstring &path)
Definition regread.cpp:49
レジストリ書込クラス
Definition registry.h:108
void setStringData(const std::wstring &name, const std::wstring &val)
Definition regwrite.cpp:81
void setDwordData(const std::wstring &name, DWORD val)
Definition regwrite.cpp:68
RegistryWriter(RegRootKey root, const std::wstring &path)
Definition regwrite.cpp:48
Definition clkpanel.h:43
RegRootKey
Definition registry.h:53
@ REGKEY_CLASSES_ROOT
Definition registry.h:54
@ REGKEY_LOCAL_MACHINE
Definition registry.h:56
@ REGKEY_USERS
Definition registry.h:57
@ REGKEY_CURRENT_CONFIG
Definition registry.h:58
@ REGKEY_CURRENT_USER
Definition registry.h:55