YSTest: Registry.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

Registry.h
浏览该文件的文档.
1 /*
2 © 2013-2016, 2018 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
29 #ifndef YCL_MinGW32_INC_Registry_h_
30 #define YCL_MinGW32_INC_Registry_h_ 1
31
32 #include "YCLib/YModules.h"
33 #include YFM_Win32_YCLib_MinGW32 // for platform::Nonnull, wstring, vector,
34 // pair;
35
36 namespace platform_ex
37 {
38
39 inline namespace Windows
40 {
41
48 class YF_API RegistryKey
49 {
50 private:
51 ::HKEY h_key;
52
53 public:
59 YB_NONNULL(2)
60 RegistryKey(::HKEY h_parent, const wchar_t* name, unsigned long ul_opt = 0,
61 ::REGSAM access = KEY_READ)
62 {
63 YCL_RaiseZ_Win32E(::RegOpenKeyExW(h_parent,
64 platform::Nonnull(name), ul_opt, access, &h_key), "RegOpenKeyEx");
65 }
67 RegistryKey(RegistryKey&& key)
68 : h_key(key.h_key)
69 {
70 key.h_key = {};
71 }
72 ~RegistryKey()
73 {
74 ::RegCloseKey(h_key);
75 }
76
77 DefDeMoveAssignment(RegistryKey)
78
79 DefGetter(const ynothrow, ::HKEY, Key, h_key)
90 pair<unsigned long, vector<byte>>
91 GetRawValue(const wchar_t*, unsigned long = REG_NONE) const;
96 PDefH(pair<unsigned long YPP_Comma vector<byte>>, GetRawValue,
97 wstring_view name, unsigned long type = REG_NONE) const
98 ImplRet(GetRawValue(name.data(), type))
100 size_t
101 GetSubKeyCount() const;
103 vector<wstring>
104 GetSubKeyNames() const;
105 size_t
106 GetValueCount() const;
108 vector<wstring>
109 GetValueNames() const;
110
112 void
113 Flush();
114 };
115
125 YF_API YB_NONNULL(2) wstring
126 FetchRegistryString(const RegistryKey&, const wchar_t*);
127 YB_NONNULL(2, 3) inline PDefH(wstring, FetchRegistryString,
128 ::HKEY h_parent, const wchar_t* key_name, const wchar_t* name)
129 ImplRet(FetchRegistryString(RegistryKey(h_parent, key_name), name))
131
132 } // inline namespace Windows;
133
134 } // namespace platform_ex;
135
136 #endif
137
platform::Nonnull
YB_PURE _type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:518
platform_ex::Windows::PDefH
YB_ATTR_nodiscard YB_STATELESS yconstfn PDefH(bool, IsDirectory, FileAttributes attr) ynothrow ImplRet(attr &Directory) YB_ATTR_nodiscard YB_STATELESS inline PDefH(bool
判断 FileAttributes 是否指定目录。
ystdex::cpp2017::basic_string
Definition: string.hpp:77
platform_ex
平台扩展命名空间。
Definition: Android.h:46
ystdex::cpp2017::wstring_view
basic_string_view< wchar_t > wstring_view
Definition: string_view.hpp:440
YF_API
#define YF_API
Definition: Platform.h:56
YPP_Comma
#define YPP_Comma
替换为逗号的预处理记号。
Definition: ydef.h:370
platform_ex::Windows::RegistryKey::~RegistryKey
~RegistryKey()
Definition: Registry.h:72
platform_ex::Windows::FetchRegistryString
YF_API const wchar_t FetchRegistryString
Definition: Registry.h:127
platform_ex::Windows::ImplRet
YB_ATTR_nodiscard YB_STATELESS yconstfnconst ::WIN32_FIND_DATAA &d ynothrow ImplRet(IsDirectory(FileAttributes(d.dwFileAttributes))) YB_ATTR_nodiscard YB_STATELESS inline PDefH(bool
判断 ::WIN32_FIND_DATAW 指定的节点是否为目录。
YSLib::UI::Styles::Key
pair< std::type_index, StyleItem > Key
标识查找样式的键。
Definition: YStyle.h:380
platform_ex::Windows::h_parent
YF_API const wchar_t ::HKEY h_parent
Definition: Registry.h:128
ystdex::cpp2017::data
auto data(_tRange &c) -> decltype(c.data())
Definition: range.hpp:581
platform_ex::Windows::RegistryKey::DefDeMoveAssignment
DefDeMoveAssignment(RegistryKey) DefGetter(const ynothrow
platform_ex::Windows::RegistryKey
注册表键。
Definition: Registry.h:49
platform::containers::vector
std::vector< _type, _tAlloc > vector
Definition: Container.h:102
platform_ex::Windows::RegistryKey::h_key
::HKEY h_key
Definition: Registry.h:51
NPL::A1::name
const char * name
Definition: NPLA1.h:1876
platform_ex::Windows::YB_NONNULL
YF_API YB_ATTR_returns_nonnull YB_NONNULL(2) ModuleProc *LoadProc( YB_NONNULL(2) inline _func &LoadProc(
从模块加载指定过程的指针。
Definition: Win32/include/YCLib/MinGW32.h:246
platform_ex::Windows::RegistryKey::YB_NONNULL
YB_NONNULL(2) RegistryKey(
构造：使用本机键、名称、选项和访问权限。
Definition: Registry.h:59
YModules.h
YCLib 库模块配置文件。
platform_ex::Windows::RegistryKey::RegistryKey
RegistryKey(RegistryKey &&key)
Definition: Registry.h:67
platform_ex::Windows::key_name
YF_API const wchar_t ::HKEY const wchar_t * key_name
Definition: Registry.h:128
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:1199
YCL_RaiseZ_Win32E
#define YCL_RaiseZ_Win32E(_expr,...)
按表达式求值和指定参数抛出 Windows::Win32Exception 对象。
Definition: Win32/include/YCLib/MinGW32.h:156