CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
registry.h
1
2#ifndef _MICROSOFT_WIN32_REGISTRY_H_
3#define _MICROSOFT_WIN32_REGISTRY_H_
4
5#include <system/object.h>
6#include <system/shared_ptr.h>
7#include <system/array.h>
8#include <system/string.h>
9#include <system/reflection.h>
10#include <limits>
11#include <cstdint>
12#include <defines.h>
13
14namespace Microsoft
15{
16namespace Win32
17{
18
19class SafeRegistryHandle;
20class RegistrySecurity;
21
23enum class RegistryView
24{
26 Default = 0,
28 Registry64 = 256,
30 Registry32 = 512
31};
32
34enum class RegistryHive
35{
37 ClassesRoot = (std::numeric_limits<int32_t>::min)(),
39 CurrentUser = -2147483647,
41 LocalMachine = -2147483646,
43 Users = -2147483645,
45 PerformanceData = -2147483644,
47 CurrentConfig = -2147483643,
49 DynData = -2147483642
50};
51
54{
56 Default = 0,
58 ReadSubTree = 1,
61};
62
65{
67 None = 0,
69 Volatile = 1
70};
71
74{
76 None = 0,
78 Audit = 1,
80 Access = 2,
82 Owner = 4,
84 Group = 8,
86 All = 15
87};
88
91{
93 None = 0,
96};
97
100{
102 None = -1,
104 Unknown = 0,
106 String = 1,
108 ExpandString = 2,
110 Binary = 3,
112 DWord = 4,
114 MultiString = 7,
116 QWord = 11
117};
118
121{
123 QueryValues = 1,
125 SetValue = 2,
127 CreateSubKey = 4,
131 Notify = 16,
133 CreateLink = 32,
135 Delete = 65536,
137 ReadPermissions = 131072,
139 WriteKey = 131078,
141 ExecuteKey = 131097,
143 ReadKey = 131097,
145 ChangePermissions = 262144,
147 TakeOwnership = 524288,
149 FullControl = 983103
150};
151
152struct Registry;
153
159class ASPOSECPP_SHARED_CLASS RegistryKey : public System::Object
160{
161 friend struct Registry;
163 RTTI_INFO(Microsoft::Win32::RegistryKey, ::System::BaseTypesInfo<System::Object>)
164
165private:
167 friend struct Registry;
168
170 void* m_key;
172 bool m_systemKey;
173
175 RegistryKey();
176 MEMBER_FUNCTION_MAKE_OBJECT(RegistryKey, CODEPORTING_ARGS(), CODEPORTING_ARGS());
177
181 RegistryKey(void* hkey, bool systemKey);
182
186 static System::SharedPtr<RegistryKey> GetBaseKey(void* hkey);
187
188public:
190 virtual ASPOSECPP_SHARED_API ~RegistryKey() override;
191
195 ASPOSECPP_SHARED_API System::String get_Name();
197 ASPOSECPP_SHARED_API int get_SubKeyCount();
199 ASPOSECPP_SHARED_API int get_ValueCount();
201 ASPOSECPP_SHARED_API RegistryView get_View();
202
210 static ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> OpenRemoteBaseKey(RegistryHive hKey, const System::String& machineName);
212 static ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> OpenRemoteBaseKey(RegistryHive hKey, const System::String& machineName, RegistryView view);
213
215 ASPOSECPP_SHARED_API void Close();
216
218 ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> CreateSubKey(const System::String& subkey);
220 ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> CreateSubKey(const System::String& subkey, RegistryKeyPermissionCheck permissionCheck);
222 ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> CreateSubKey(const System::String& subkey, RegistryKeyPermissionCheck permissionCheck, const System::SharedPtr<RegistrySecurity>& registrySecurity);
224 ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> CreateSubKey(const System::String& subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options);
226 ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> CreateSubKey(const System::String& subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, const System::SharedPtr<RegistrySecurity>& registrySecurity);
227
229 ASPOSECPP_SHARED_API void DeleteSubKey(const System::String& subkey);
231 ASPOSECPP_SHARED_API void DeleteSubKey(const System::String& subkey, bool throwOnMissingSubKey);
233 ASPOSECPP_SHARED_API void DeleteSubKeyTree(const System::String& subkey);
235 ASPOSECPP_SHARED_API void DeleteSubKeyTree(const System::String& subkey, bool throwOnMissingSubKey);
237 ASPOSECPP_SHARED_API void DeleteValue(const System::String& name);
239 ASPOSECPP_SHARED_API void DeleteValue(const System::String& name, bool throwOnMissingValue);
241 ASPOSECPP_SHARED_API void Dispose();
243 ASPOSECPP_SHARED_API void Flush();
244
251
255 ASPOSECPP_SHARED_API System::SharedPtr<System::Object> GetValue(const System::String& valueName);
261 ASPOSECPP_SHARED_API RegistryValueKind GetValueKind(const System::String& name);
265
271 ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> OpenSubKey(const System::String& name, RegistryKeyPermissionCheck permissionCheck);
273 ASPOSECPP_SHARED_API System::SharedPtr<RegistryKey> OpenSubKey(const System::String& name, bool writable);
276
278 ASPOSECPP_SHARED_API void SetAccessControl(const System::SharedPtr<RegistrySecurity>& registrySecurity);
279
281 ASPOSECPP_SHARED_API void SetValue(const System::String& name, const System::SharedPtr<System::Object>& value);
283 ASPOSECPP_SHARED_API void SetValue(const System::String& name, const System::SharedPtr<System::Object>& value, RegistryValueKind valueKind);
284
286 ASPOSECPP_SHARED_API System::String ToString() const override;
287};
288
293{
295 static const System::SharedPtr<RegistryKey> ASPOSECPP_SHARED_API ClassesRoot;
297 static const System::SharedPtr<RegistryKey> ASPOSECPP_SHARED_API CurrentConfig;
299 static const System::SharedPtr<RegistryKey> ASPOSECPP_SHARED_API CurrentUser;
301 static const System::SharedPtr<RegistryKey> ASPOSECPP_SHARED_API DynData;
303 static const System::SharedPtr<RegistryKey> ASPOSECPP_SHARED_API LocalMachine;
305 static const System::SharedPtr<RegistryKey> ASPOSECPP_SHARED_API PerformanceData;
307 static const System::SharedPtr<RegistryKey> ASPOSECPP_SHARED_API Users;
308
316 static ASPOSECPP_SHARED_API System::SharedPtr<System::Object> GetValue(const System::String& keyName, const System::String& valueName, const System::SharedPtr<System::Object>& defaultValue);
322 static ASPOSECPP_SHARED_API void SetValue(const System::String& keyName, const System::String& valueName, const System::SharedPtr<System::Object>& value);
329 static ASPOSECPP_SHARED_API void SetValue(const System::String& keyName, const System::String& valueName, const System::SharedPtr<System::Object>& value, RegistryValueKind valueKind);
330};
331
332}
333}
334
335#endif // _MICROSOFT_WIN32_REGISTRY_H_
API to manipulate registry values. Support is very limited and Windows-only. Objects of this class sh...
Definition: registry.h:160
System::ArrayPtr< System::String > GetSubKeyNames()
Enumerates subkeys. Not implemented.
void DeleteSubKeyTree(const System::String &subkey, bool throwOnMissingSubKey)
Deletes subkey tree under current key. Not implemented.
void DeleteSubKeyTree(const System::String &subkey)
Deletes subkey tree under current key. Not implemented.
RegistryValueKind GetValueKind(const System::String &name)
Gets key value type. Not implemented.
void Dispose()
Frees handles associated with key. Not implemented.
System::SharedPtr< RegistryKey > OpenSubKey(const System::String &name, bool writable)
Opens subkey of current key. Not implemented.
void DeleteValue(const System::String &name)
Deletes value of current key. Not implemented.
static System::SharedPtr< RegistryKey > OpenRemoteBaseKey(RegistryHive hKey, const System::String &machineName, RegistryView view)
Opens base key on remote host. Not implemented.
void SetValue(const System::String &name, const System::SharedPtr< System::Object > &value, RegistryValueKind valueKind)
Sets registry value. Not implemented.
void DeleteSubKey(const System::String &subkey)
Deletes subkey under current key. Not implemented.
static System::SharedPtr< RegistryKey > OpenBaseKey(RegistryHive hKey, RegistryView view)
Opens base key. Not implemented.
void Flush()
Writes all attributes of key to registry. Not implemented.
System::SharedPtr< System::Object > GetValue(const System::String &name, const System::SharedPtr< System::Object > &defaultValue)
Gets key value. Not implemented.
void DeleteSubKey(const System::String &subkey, bool throwOnMissingSubKey)
Deletes subkey under current key. Not implemented.
System::SharedPtr< RegistryKey > CreateSubKey(const System::String &subkey, RegistryKeyPermissionCheck permissionCheck)
Creates subkey under current key. Not implemented.
System::SharedPtr< RegistryKey > CreateSubKey(const System::String &subkey, RegistryKeyPermissionCheck permissionCheck, const System::SharedPtr< RegistrySecurity > &registrySecurity)
Creates subkey under current key. Not implemented.
virtual ~RegistryKey() override
Destructor.
System::SharedPtr< SafeRegistryHandle > get_Handle()
Gets raw handle of registry key. Not implemented.
static System::SharedPtr< RegistryKey > FromHandle(const System::SharedPtr< SafeRegistryHandle > &handle)
Opens key from handle. Not implemented.
void SetValue(const System::String &name, const System::SharedPtr< System::Object > &value)
Sets registry value. Not implemented.
System::SharedPtr< RegistryKey > CreateSubKey(const System::String &subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions options)
Creates subkey under current key. Not implemented.
RegistryView get_View()
Gets view of registry key. Not implemented.
System::SharedPtr< RegistrySecurity > GetAccessControl()
Gets access control object associated with key. Not implemented.
System::SharedPtr< RegistryKey > CreateSubKey(const System::String &subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions, const System::SharedPtr< RegistrySecurity > &registrySecurity)
Creates subkey under current key. Not implemented.
void DeleteValue(const System::String &name, bool throwOnMissingValue)
Deletes value of current key. Not implemented.
int get_ValueCount()
Gets number of values. Not implemented.
System::String ToString() const override
Converts key to string. Not implemented.
System::SharedPtr< RegistryKey > OpenSubKey(const System::String &name, RegistryKeyPermissionCheck permissionCheck)
Opens subkey of current key. Not implemented.
System::SharedPtr< RegistryKey > CreateSubKey(const System::String &subkey)
Creates subkey under current key. Not implemented.
System::SharedPtr< RegistryKey > OpenSubKey(const System::String &name, RegistryKeyPermissionCheck permissionCheck, RegistryRights rights)
Opens subkey of current key. Not implemented.
System::SharedPtr< RegistrySecurity > GetAccessControl(AccessControlSections includeSections)
Gets access control object associated with key. Not implemented.
System::ArrayPtr< System::String > GetValueNames()
Gets list of value names under current key.
void Close()
Closes registry key. Not implemented.
System::SharedPtr< RegistryKey > OpenSubKey(const System::String &name)
Opens subkey of current key.
System::SharedPtr< System::Object > GetValue(const System::String &valueName)
Gets key value. Windows only.
System::String get_Name()
Gets name of registry key. Not implemented.
static System::SharedPtr< RegistryKey > FromHandle(const System::SharedPtr< SafeRegistryHandle > &handle, RegistryView view)
Opens key from handle. Not implemented.
int get_SubKeyCount()
Gets number of subkeys. Not implemented.
static System::SharedPtr< RegistryKey > OpenRemoteBaseKey(RegistryHive hKey, const System::String &machineName)
Opens base key on remote host. Not implemented.
System::SharedPtr< System::Object > GetValue(const System::String &name, const System::SharedPtr< System::Object > &defaultValue, RegistryValueOptions options)
Gets key value. Not implemented.
void SetAccessControl(const System::SharedPtr< RegistrySecurity > &registrySecurity)
Sets access control value. Not implemented.
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
RegistryView
Defines which of the registry views to use on 64-bit Windows.
Definition: registry.h:24
@ Registry32
Use 32-bit registry view.
@ Registry64
Use 64-bit registry view.
RegistryOptions
Registry keys creation options.
Definition: registry.h:65
@ Volatile
Keep value in memory only.
AccessControlSections
Specifies which part of security descriptor to save or load.
Definition: registry.h:74
RegistryRights
Registry access rights.
Definition: registry.h:121
@ TakeOwnership
Ownership taking.
@ ExecuteKey
Key execution permissions mask.
@ EnumerateSubKeys
Listing subkeys.
@ CreateSubKey
Creating subkeys.
@ ReadKey
Key reading permissions mask.
@ FullControl
Full control mask.
@ Notify
Sending notifications.
@ ReadPermissions
Reading permissions mask.
@ WriteKey
Key writing permissions mask.
@ ChangePermissions
Permission change.
RegistryKeyPermissionCheck
Defines how the security checks are performed on registry entries.
Definition: registry.h:54
@ ReadWriteSubTree
No security checks when reading or writing subtree.
@ ReadSubTree
No security checks when reading subtree.
RegistryValueKind
Type of registry value.
Definition: registry.h:100
RegistryValueOptions
Registry value write mode.
Definition: registry.h:91
@ DoNotExpandEnvironmentNames
Without environment names expansion.
RegistryHive
Defines which registry root item to use as base on remote machine.
Definition: registry.h:35
@ LocalMachine
Use HKEY_LOCAL_MACHINE.
@ ClassesRoot
Use HKEY_CLASSES_ROOT.
@ DynData
Use HKEY_DYN_DATA.
@ CurrentConfig
Use HKEY_CURRENT_CONFIG.
@ PerformanceData
Use HKEY_PERFORMANCE_DATA.
@ CurrentUser
Use HKEY_CURRENT_USER.
Definition: registry.h:15
Windows system registry API. This is a static type with no instance services. You should never create...
Definition: registry.h:293
static const System::SharedPtr< RegistryKey > PerformanceData
HKEY_PERFORMANCE_DATA key.
Definition: registry.h:305
static const System::SharedPtr< RegistryKey > DynData
HKEY_DYN_DATA key.
Definition: registry.h:301
static System::SharedPtr< System::Object > GetValue(const System::String &keyName, const System::String &valueName, const System::SharedPtr< System::Object > &defaultValue)
Gets value of specified key. Not implemented.
static const System::SharedPtr< RegistryKey > CurrentUser
HKEY_CURRENT_USER key.
Definition: registry.h:299
static const System::SharedPtr< RegistryKey > CurrentConfig
HKEY_CURRENT_CONFIG key.
Definition: registry.h:297
static const System::SharedPtr< RegistryKey > ClassesRoot
HKEY_CLASSES_ROOT key.
Definition: registry.h:295
static const System::SharedPtr< RegistryKey > Users
HKEY_USERS key.
Definition: registry.h:307
static void SetValue(const System::String &keyName, const System::String &valueName, const System::SharedPtr< System::Object > &value, RegistryValueKind valueKind)
Sets value of specified key. Not implemented.
static const System::SharedPtr< RegistryKey > LocalMachine
HKEY_LOCAL_MACHINE key.
Definition: registry.h:303
static void SetValue(const System::String &keyName, const System::String &valueName, const System::SharedPtr< System::Object > &value)
Sets value of specified key. Not implemented.