17#if defined(__BORLANDC__)
34 static TRegKey ClassesRoot(HKEY_CLASSES_ROOT,
true,
_T(
"HKEY_CLASSES_ROOT"));
44 return ClassesRootClsid;
57 static TRegKey CurrentConfig(HKEY_CURRENT_CONFIG,
true,
_T(
"HKEY_CURRENT_CONFIG"));
74 static TRegKey CurrentUser(HKEY_CURRENT_USER,
true,
_T(
"HKEY_CURRENT_USER"));
89 static TRegKey LocalMachine(HKEY_LOCAL_MACHINE,
true,
_T(
"HKEY_LOCAL_MACHINE"));
100 static TRegKey PerformanceData(HKEY_PERFORMANCE_DATA,
true,
_T(
"HKEY_PERFORMANCE_DATA"));
101 return PerformanceData;
112 static TRegKey Users(HKEY_USERS,
true,
_T(
"HKEY_USERS"));
135 const auto init = [&]()
noexcept ->
long
141 auto disposition = DWORD{};
142 const auto r = ::RegCreateKeyEx(baseKey,
Name.c_str(), 0 ,
nullptr ,
143 REG_OPTION_NON_VOLATILE, samDesired,
nullptr , &
Key, &disposition);
144 if (r != ERROR_SUCCESS)
return r;
148 const auto r = ::RegOpenKeyEx(baseKey,
Name.c_str(), 0 , samDesired, &
Key);
149 if (r != ERROR_SUCCESS)
return r;
152 if (r != ERROR_SUCCESS && r != ERROR_INSUFFICIENT_BUFFER)
return r;
153 return ERROR_SUCCESS;
158 if (x == EXCEPTION_ACCESS_VIOLATION)
return ERROR_ACCESS_DENIED;
159 RaiseException(x, 0, 0,
nullptr);
163 const auto r = init();
164 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegKey::TRegKey: Init failed"),
Name, r};
174 :
TRegKey{baseKey, keyName ? keyName :
tstring{}, samDesired, createOK}
190 const auto init = [&]()
noexcept ->
long
196 if (re != ERROR_SUCCESS)
return re;
198 const auto ro = ::RegOpenKeyEx(iter.
BaseKey(),
Name.c_str(), 0, samDesired, &
Key);
199 if (ro != ERROR_SUCCESS)
return ro;
201 if (rq != ERROR_SUCCESS && rq != ERROR_INSUFFICIENT_BUFFER)
return rq;
202 return ERROR_SUCCESS;
207 if (x == EXCEPTION_ACCESS_VIOLATION)
return ERROR_ACCESS_DENIED;
208 RaiseException(x, 0, 0,
nullptr);
212 const auto r = init();
213 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegKey::TRegKey: Init failed"),
Name, r};
238 const auto init = [&]()
noexcept ->
long
243 if (r != ERROR_SUCCESS && r != ERROR_INSUFFICIENT_BUFFER)
return r;
244 return ERROR_SUCCESS;
249 if (x == EXCEPTION_ACCESS_VIOLATION)
return ERROR_ACCESS_DENIED;
250 RaiseException(x, 0, 0,
nullptr);
254 const auto r = init();
255 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegKey::TRegKey: Init failed"),
Name, r};
274 :
Key{}, Name{}, SubkeyCount{}, ValueCount{}, ShouldClose{}
279 swap(SubkeyCount, v.SubkeyCount);
280 swap(ValueCount, v.ValueCount);
281 swap(ShouldClose, v.ShouldClose);
282 WARN(!Key,
_T(
"TRegKey::TRegKey: Moved from invalid key"));
292 [[maybe_unused]]
const auto r = ::RegCloseKey(
Key);
293 WARN(r != ERROR_SUCCESS,
_T(
"TRegKey::~TRegKey: RegCloseKey failed, error: ") << r);
303 DWORD* subkeyCount, DWORD* maxSubkeyNameSize, DWORD* maxSubkeyClassSize,
304 DWORD* valueCount, DWORD* maxValueNameSize, DWORD* maxValueDataSize,
305 DWORD* securityDescriptorSize, PFILETIME lastWriteTime)
const
307 return ::RegQueryInfoKey(
Key,
317 securityDescriptorSize,
330 i.
Class.resize(classSize);
331 const auto p =
const_cast<LPTSTR
>(i.Class.data());
336 &i.MaxSubkeyNameSize,
337 &i.MaxSubkeyClassSize,
341 &i.SecurityDescriptorSize,
343 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegKey::QueryInfo failed"), *
this, r};
344 i.Class.resize(classSize);
345 i.Class.shrink_to_fit();
357 auto subkey = HKEY{};
358 const auto r = ::RegOpenKeyEx(
Key, keyName.c_str(), 0, KEY_READ, &subkey);
360 ::RegCloseKey(subkey);
361 return r != ERROR_FILE_NOT_FOUND;
379 auto subkey = HKEY{};
380 const auto r = ::RegOpenKeyEx(
Key, keyName.c_str(), 0, samDesired, &subkey);
381 if (r != ERROR_SUCCESS && r != ERROR_FILE_NOT_FOUND)
throw TXRegistry{
_T(
"TRegKey::GetSubKey: RegOpenKeyEx failed"), keyName, r};
382 return subkey ? make_optional<TRegKey>(subkey,
true, keyName) : nullopt;
393 return QueryValue(valueName,
nullptr,
nullptr,
nullptr) != ERROR_FILE_NOT_FOUND;
405 return HasValue(valueName) ? make_optional<TRegValue>(*
this, valueName) : nullopt;
415 const auto nukeSubkeys = [&](LPCTSTR keyName)
417 auto key =
GetSubkey(keyName, KEY_ALL_ACCESS);
418 if (!key)
return ERROR_FILE_NOT_FOUND;
419 auto subkeys = vector<tstring>{};
421 subkeys.push_back(
TRegKey{i}.GetName());
422 for (
const auto& s : subkeys)
424 const auto r = key->NukeKey(s);
425 if (r != ERROR_SUCCESS)
return r;
427 return ERROR_SUCCESS;
429 const auto r = nukeSubkeys(subKeyName);
430 if (r != ERROR_SUCCESS)
return r;
454 : Data(key.
QueryInfo().SecurityDescriptorSize)
456 auto n =
static_cast<DWORD
>(Data.size());
457 const auto r = key.
GetSecurity(infoRequested, Data.data(), &n);
458 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TSecurityDescriptor::TSecurityDescriptor: GetSecurity failed"), key, r};
459 CHECK(n ==
static_cast<DWORD
>(Data.size()));
470 return ::IsValidSecurityDescriptor(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData())) != FALSE;
486 auto c = SECURITY_DESCRIPTOR_CONTROL{};
487 auto revision = DWORD{};
488 const auto ok = ::GetSecurityDescriptorControl(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()), &c, &revision);
489 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::GetControl: GetSecurityDescriptorControl failed"),
tstring{},
static_cast<long>(::GetLastError())};
506 return ::GetSecurityDescriptorLength(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()));
528 auto daclPresent = BOOL{};
530 auto daclDefaulted = BOOL{};
531 const auto ok = ::GetSecurityDescriptorDacl(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()), &daclPresent, &dacl, &daclDefaulted);
532 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::GetDacl: GetSecurityDescriptorDacl failed"),
tstring{},
static_cast<long>(::GetLastError())};
533 return daclPresent ? make_optional(dacl) : nullopt;
552 auto groupDefaulted = BOOL{};
553 const auto ok = ::GetSecurityDescriptorGroup(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()), &group, &groupDefaulted);
554 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::GetGroup: GetSecurityDescriptorGroup failed"),
tstring{},
static_cast<long>(::GetLastError())};
574 auto ownerDefaulted = BOOL{};
575 const auto ok = ::GetSecurityDescriptorOwner(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()), &owner, &ownerDefaulted);
576 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::GetOwner: GetSecurityDescriptorOwner failed"),
tstring{},
static_cast<long>(::GetLastError())};
593 auto c = SECURITY_DESCRIPTOR_CONTROL{};
594 auto revision = DWORD{};
595 const auto ok = ::GetSecurityDescriptorControl(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()), &c, &revision);
596 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::GetRevision: GetSecurityDescriptorControl failed"),
tstring{},
static_cast<long>(::GetLastError())};
615 auto rmControl = UCHAR{};
616 const auto r = ::GetSecurityDescriptorRMControl(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()), &rmControl);
617 if (r == ERROR_INVALID_DATA)
return nullopt;
618 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::GetRmControl: GetSecurityDescriptorRMControl failed"),
tstring{},
static_cast<long>(r)};
619 return make_optional(rmControl);
641 auto saclPresent = BOOL{};
643 auto saclDefaulted = BOOL{};
644 const auto ok = ::GetSecurityDescriptorSacl(
const_cast<SECURITY_DESCRIPTOR*
>(
GetData()), &saclPresent, &sacl, &saclDefaulted);
645 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::GetSacl: GetSecurityDescriptorSacl failed"),
tstring{},
static_cast<long>(::GetLastError())};
646 return saclPresent ? make_optional(sacl) : nullopt;
664 const auto ok = ::InitializeSecurityDescriptor(
GetData(), revision);
665 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::Initialize: InitializeSecurityDescriptor failed"),
tstring{},
static_cast<long>(::GetLastError())};
680 const auto ok = ::SetSecurityDescriptorDacl(
GetData(), FALSE,
nullptr, FALSE);
681 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::RemoveDacl: SetSecurityDescriptorDacl failed"),
tstring{},
static_cast<long>(::GetLastError())};
697 const auto ok = ::SetSecurityDescriptorGroup(
GetData(),
nullptr, FALSE);
698 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::RemoveGroup: SetSecurityDescriptorGroup failed"),
tstring{},
static_cast<long>(::GetLastError())};
713 const auto ok = ::SetSecurityDescriptorOwner(
GetData(),
nullptr, FALSE);
714 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::RemoveOwner: SetSecurityDescriptorOwner failed"),
tstring{},
static_cast<long>(::GetLastError())};
728 const auto r = ::SetSecurityDescriptorRMControl(
GetData(),
nullptr);
729 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::RemoveRmControl: SetSecurityDescriptorRMControl failed"),
tstring{},
static_cast<long>(r)};
744 const auto ok = ::SetSecurityDescriptorSacl(
GetData(), FALSE,
nullptr, FALSE);
745 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::RemoveSacl: SetSecurityDescriptorSacl failed"),
tstring{},
static_cast<long>(::GetLastError())};
772 const auto ok = ::SetSecurityDescriptorDacl(
GetData(), TRUE, dacl, daclDefaulted ? TRUE : FALSE);
773 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::SetDacl: SetSecurityDescriptorDacl failed"),
tstring{},
static_cast<long>(::GetLastError())};
799 const auto ok = ::SetSecurityDescriptorGroup(
GetData(), group, groupDefaulted ? TRUE : FALSE);
800 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::SetGroup: SetSecurityDescriptorGroup failed"),
tstring{},
static_cast<long>(::GetLastError())};
826 const auto ok = ::SetSecurityDescriptorOwner(
GetData(), owner, ownerDefaulted ? TRUE : FALSE);
827 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::SetOwner: SetSecurityDescriptorOwner failed"),
tstring{},
static_cast<long>(::GetLastError())};
844 const auto r = ::SetSecurityDescriptorRMControl(
GetData(), &rmControl);
845 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::SetRmControl: SetSecurityDescriptorRMControl failed"),
tstring{},
static_cast<long>(r)};
871 const auto ok = ::SetSecurityDescriptorSacl(
GetData(), TRUE, sacl, saclDefaulted ? TRUE : FALSE);
872 if (!ok)
throw TXRegistry{
_T(
"TRegKey::TSecurityDescriptor::SetSacl: SetSecurityDescriptorSacl failed"),
tstring{},
static_cast<long>(::GetLastError())};
881 Key(key), Name(name ? name :
_T(
"")), DataType(REG_NONE), Data(0), DataSize(0)
892 Key(key), Name(name), DataType(REG_NONE), Data(0), DataSize(0)
897#if defined(BI_COMP_BORLANDC)
911long TRegValue::QueryTypeAndSize()
913 long r = Key.
QueryValue(Name, &DataType,
nullptr, &DataSize);
914 WARN(r != ERROR_SUCCESS,
_T(
"TRegValue::QueryTypeAndSize: Query failed: ") << Key.
GetName() <<
_T(
'\\') << Name <<
_T(
", error: ") << r);
923 Key(iter.BaseKey()), Name(), DataType(REG_NONE), Data(0), DataSize(0)
926 std::vector<tchar> nameBuffer(nameSize);
927 long r = Key.EnumValue(iter.
Current(), &nameBuffer[0], nameSize, &DataType,
nullptr, &DataSize);
928 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegValue::TRegValue(const TRegValueIterator&): EnumValue failed"), Key, r};
929 nameBuffer.resize(nameSize);
930 Name.assign(nameBuffer.begin(), nameBuffer.end());
940 if (DataType != REG_DWORD && DataType != REG_DWORD_BIG_ENDIAN)
941 throw TXRegistry{
_T(
"TRegValue::operator uint32: Incompatible data type"), Key};
944 return *
reinterpret_cast<uint32*
>(&Data[0]);
954 if (DataType != REG_QWORD)
955 throw TXRegistry{
_T(
"TRegValue::operator uint64: Incompatible data type"), Key};
958 return *
reinterpret_cast<uint64*
>(&Data[0]);
965TRegValue::operator LPCTSTR()
const
968 if (DataType != REG_SZ &&
969 DataType != REG_MULTI_SZ &&
970 DataType != REG_EXPAND_SZ &&
971 !(DataType == REG_LINK &&
sizeof(
tchar) == 2)
973 throw TXRegistry{
_T(
"TRegValue::operator LPCTSTR: Incompatible data type"), Key};
979 CHECK(!Data.empty());
980 LPTSTR s =
reinterpret_cast<LPTSTR
>(&Data[0]);
981 const size_t n = Data.size() /
sizeof(
tchar);
982 if (n == 0)
throw TXRegistry{
_T(
"TRegValue::operator LPCTSTR: Data size is zero"), Key};
983 WARN((Data.size() %
sizeof(
tchar)) != 0,
_T(
"TRegValue::operator LPCTSTR: Oddly sized string"));
984 WARN(s[n - 1] !=
_T(
'\0'),
_T(
"TRegValue::operator LPCTSTR: String lacks null-termination"));
986 if (DataType == REG_MULTI_SZ && n > 1)
988 WARN(s[n - 2] !=
_T(
'\0'),
_T(
"TRegValue::operator LPCTSTR: Multi-string lacks double null-termination"));
1001 return Data.empty() ? nullptr : &Data[0];
1012 long r = Key.SetValue(Name, type, data, dataSize);
1013 if (r != ERROR_SUCCESS)
return r;
1018 if (dataSize == Data.size() && !Data.empty())
1020 memcpy(&Data[0], data, Data.size());
1024 DataSize = dataSize;
1027 return ERROR_SUCCESS;
1037 const uint8* data =
reinterpret_cast<const uint8*
>(&v);
1039 return Set(REG_DWORD, data, dataSize);
1049 const uint8* data =
reinterpret_cast<const uint8*
>(&v);
1051 return Set(REG_QWORD, data, dataSize);
1061 const uint8* data =
reinterpret_cast<const uint8*
>(v);
1063 return Set(REG_SZ, data, dataSize);
1074 bool isMultiString = (!v.empty() && *v.rbegin() ==
_T(
'\0'));
1075 const uint8* data =
reinterpret_cast<const uint8*
>(v.c_str());
1076 uint32 dataSize =
static_cast<uint32>((v.size() + 1) *
sizeof(tstring::value_type));
1077 uint32 dataType = isMultiString ? REG_MULTI_SZ : REG_SZ;
1078 return Set(dataType, data, dataSize);
1089 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegValue::operator =(uint32): Set failed"), Key, r};
1101 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegValue::operator =(uint64): Set failed"), Key, r};
1113 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegValue::operator =(LPCTSTR): Set failed"), Key, r};
1125 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegValue::operator =(const tstring&): Set failed"), Key, r};
1135 long r = Key.DeleteValue(Name);
1136 if (r != ERROR_SUCCESS)
return r;
1137 DataType = REG_NONE;
1138 try {std::vector<uint8>().swap(Data);}
1139 catch (...) {Data.clear();}
1141 return ERROR_SUCCESS;
1150TRegValue::RetrieveOnDemand()
const
1152 if (!Data.empty())
return;
1153 if (DataType == REG_NONE || DataSize == 0)
throw TXRegistry{
_T(
"TRegValue::RetrieveOnDemand: Value is void"), Key};
1155 uint32 dataType = DataType;
1156 Data.resize(DataSize);
1157 uint32 dataSize = DataSize;
1158 long r = Key.
QueryValue(Name, &dataType, &Data[0], &dataSize);
1159 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegValue::RetrieveOnDemand: QueryValue failed"), Key, r};
1160 if (dataType != DataType)
throw TXRegistry{
_T(
"TRegValue::RetrieveOnDemand: Type changed"), Key};
1161 if (dataSize != DataSize)
throw TXRegistry{
_T(
"TRegValue::RetrieveOnDemand: Size changed"), Key};
1177 for (Count = 0; List[Count]; Count++)
1179 EnabledFlags =
new int8[Count];
1187 delete[] EnabledFlags;
1196 for (LPCTSTR pc = set; *pc != 0; pc++)
1197 EnabledFlags[*pc - 1] = 0;
1206 for (LPCTSTR pc = set; *pc != 0; pc++)
1207 EnabledFlags[*pc - 1]++;
1222 for (Count = 0; List[Count].Param; Count++)
1224 typedef LPCTSTR cpchar;
1225 Values =
new cpchar[Count];
1242 for (
int i = Count; --i >= 0; )
1243 Values[i] = List[i].Default;
1258 if (
_tcscmp(List[i].Param, param) == 0)
1304 for (; item && item->
Key; item++) {
1307 if (*item->
Key ==
' ') {
1315 if (i < 0)
throw TXRegistry{
_T(
"TRegSymbolTable::UpdateParams failed"), k};
1335# define _A2WB_(val) _A2WB(val,(tchar*)conv_buf)
1337# define _A2WB_(val) val
1344 LPCTSTR userval = 0;
1355 userval = item->
Value;
1361 const int bufSize = 512;
1387 if (*pc == 0 && *pt ==
_T(
' '))
1397 while (*(pb-1) ==
_T(
' '))
1401 while (*pt ==
_T(
' '))
1423 <<
_T(
'\\') << (LPCTSTR)buf;
1425 out <<
_T(
" = ") << data;
1450 if (in.peek() ==
_T(
'\\'))
1452 in.getline(entry, 512);
1459 while (*(pc-1) ==
_T(
' '))
1462 while (*(++data) ==
_T(
' '))
1467 *valName++ =
_T(
'\0');
1469 TRegKey subKey(baseKey, entry);
1470 LPCTSTR s = data ? data :
_T(
"");
1471 const uint8* buf =
reinterpret_cast<const uint8*
>(s);
1473 const auto r = subKey.
SetValue(valName, REG_SZ, buf, bufSize);
1474 if (r != ERROR_SUCCESS)
throw TXRegistry{
_T(
"TRegistry::Update: SetValue failed"), subKey};
1496 if (in.peek() ==
_T(
'\\'))
1498 in.getline(entry, 512);
1505 while (*(pc - 1) ==
_T(
' '))
1508 while (*(++data) ==
_T(
' '))
1513 *valName++ =
_T(
'\0');
1520 uint32 dataType = REG_SZ;
1523 if (subKey.
QueryValue(valName, &dataType,
reinterpret_cast<uint8*
>(buf), &bufSize) != ERROR_SUCCESS
1524 || (data &&
_tcscmp(data, buf) != 0))
1549# define _A2WB_(val) _A2WB(val,(tchar*)conv_buf)
1550# define _W2AB_(val) _W2AB(val,(tchar*)conv_buf)
1554# define _A2WB_(val) val
1555# define _W2AB_(val) val
1562 for (
int i = 0; params[i].
Name && params[i].
BaseKey; i++) {
1563 LPCTSTR regKey = regInfo[
_W2AB_(params[i].Name)];
1569 regKey = overrides->
Value;
1575 if (params[i].Prepend) {
1583 if (params[i].BaseKey->NukeKey(regKey))
#define WARN(condition, message)
#define PRECONDITION(condition)
Pointer to an array of type T.
auto GetLength() const -> DWORD
Returns the length, in bytes, of the security descriptor.
void RemoveGroup()
Removes the primary group information from the security descriptor.
void SetSacl(PACL sacl, bool saclDefaulted=false)
Sets the system access control list (SACL) of the security descriptor.
auto GetDacl() const -> std::optional< PACL >
Retrieves the discretionary access control list (DACL) from the security descriptor.
auto GetOwner() const -> PSID
Retrieves the owner information from the security descriptor.
auto GetData() noexcept -> SECURITY_DESCRIPTOR *
void RemoveOwner()
Removes the owner information from the security descriptor.
auto IsValid() const noexcept -> bool
Determines whether the components of the security descriptor are valid.
TSecurityDescriptor(const TRegKey &key, SECURITY_INFORMATION infoRequested)
Retrieves a copy of the security descriptor protecting the specified open registry key.
void SetRmControl(UCHAR rmControl)
Sets the resource manager control bits of the security descriptor.
void Initialize(DWORD revision=SECURITY_DESCRIPTOR_REVISION)
Initializes a new security descriptor.
void SetOwner(PSID owner, bool ownerDefaulted=false)
Sets the owner information of the security descriptor.
void SetGroup(PSID group, bool groupDefaulted=false)
Sets the primary group information of the security descriptor.
auto GetControl() const -> SECURITY_DESCRIPTOR_CONTROL
Retrieves the control information from the security descriptor.
auto GetRevision() const -> DWORD
Retrieves the revision number of the security descriptor structure.
void RemoveDacl()
Removes the discretionary access control list (DACL) from the security descriptor.
void SetDacl(PACL dacl, bool daclDefaulted=false)
Sets the discretionary access control list (DACL) of the security descriptor.
auto GetRmControl() const -> std::optional< UCHAR >
Retrieves the resource manager control bits from the security descriptor.
auto GetGroup() const -> PSID
Retrieves the primary group information from the security descriptor.
void RemoveSacl()
Removes the system access control list (SACL) from the security descriptor.
auto GetSacl() const -> std::optional< PACL >
Retrieves the system access control list (SACL) from the security descriptor.
void RemoveRmControl()
Removes the resource manager control bits from the security descriptor.
Encapsulates a registration key in the Windows Registry.
static auto GetClassesRoot() -> TRegKey &
Special predefined root key used by shell and OLE applications (HKEY_CLASSES_ROOT).
long NukeKey(LPCTSTR subKeyName)
Completely eliminates a child key, including any of its subkeys.
static auto GetUsers() -> TRegKey &
Special predefined root key defining the default user configuration (HKEY_USERS).
LPCTSTR GetName() const
Returns a string identifying this key.
static auto GetCurrentConfig() -> TRegKey &
Special predefined root key containing information about the current hardware profile of the local co...
auto HasSubkey(const tstring &keyName) const -> bool
Returns true if this key has a subkey with the given name.
DWORD SubkeyCount
Number of subkeys.
long DeleteKey(LPCTSTR subKeyName)
Deletes the specified subkey of this registry key.
tstring Name
This Key's Name.
long QueryInfo(TCHAR *class_, DWORD *classSize, DWORD *subkeyCount, DWORD *maxSubkeyNameSize, DWORD *maxSubkeyClassSize, DWORD *valueCount, DWORD *maxValueNameSize, DWORD *maxValueDataSize, DWORD *securityDescriptorSize, PFILETIME lastWriteTime) const
Retrieves information about this registry key.
THandle Key
This Key's Handle.
auto GetSubkey(const tstring &keyName, REGSAM samDesired=KEY_READ) const -> std::optional< TRegKey >
Returns the subkey with the given name, if it exists.
long SetValue(LPCTSTR valName, uint32 type, const uint8 *data, uint32 dataSize) const
Associates a value with this key.
auto GetSecurity(SECURITY_INFORMATION infoRequested, PSECURITY_DESCRIPTOR secDesc, DWORD *secDescSize) const -> long
Retrieves a copy of the security descriptor protecting this registry key.
~TRegKey()
Closes the underlying key handle, if owned.
auto GetValue(const tstring &valueName) const -> std::optional< TRegValue >
Returns the value with the given name, if it exists within this key.
bool ShouldClose
Should this key be closed on destruction.
long QueryValue(LPCTSTR valName, uint32 *type, uint8 *data, uint32 *dataSize) const
Retrieves the value associated with the unnamed value for this key in the registry.
static auto GetCurrentUser() -> TRegKey &
Special predefined root key defining the preferences of the current user (HKEY_CURRENT_USER).
long EnumKey(int index, TCHAR *subKeyName, int subKeyNameSize) const
Enumerates the subkeys of this registry key.
static auto GetClassesRootClsid() -> TRegKey &
Commonly used subkey by shell and OLE applications (HKEY_CLASSES_ROOT\CLSID).
static auto GetPerformanceData() -> TRegKey &
Special predefined root key used to obtain performance data (HKEY_PERFORMANCE_DATA).
auto HasValue(const tstring &valueName) const -> bool
Return true if this key has a value with the given name.
TRegKey(THandle baseKey, tstring keyName, REGSAM samDesired=KEY_ALL_ACCESS, TCreateOK createOK=CreateOK)
Creates or opens a key given a base key and a subkey name.
DWORD ValueCount
Number of value entries.
static auto GetLocalMachine() -> TRegKey &
Special predefined root key defining the physical state of the computer (HKEY_LOCAL_MACHINE).
TCreateOK
Enumeration used to specify whether a key should be created (or simply opened).
@ NoCreate
Don't create, simply open.
@ CreateOK
Create key if it does not exist.
Iterator for walking thru the subkeys of a key.
const TRegKey & BaseKey() const
Returns the registration key this iterator is bound to.
int Current() const
Returns the index to the current subkey.
A registration parameter table, composed of a list of TRegItems.
const tchar *& Value(int i)
Return the value of the param entry at the passed index.
void ResetDefaultValues()
TRegParamList(const TEntry *)
int Find(LPCTSTR param)
Looks for a given param in this param list.
void StreamOut(TRegItem *item, tostream &out)
void Init(LPCTSTR filter)
TRegTemplateList Templates
void UpdateParams(TLangId lang, TRegItem *item)
TRegSymbolTable(TRegKey &basekey, LPCTSTR tplList[], const TRegParamList::TEntry *paramList)
void DisableAll()
Disables all templates in this list.
bool IsActive(int i) const
Returns true if the template at the passed index is active, false otherwise.
void Activate(int i)
Activates the template at the passed index.
TRegTemplateList(TRegKey &basekey, LPCTSTR _list[])
int GetCount() const
Returns the number of templates in this list.
TRegKey & GetBaseKey()
Returns the registry key upon which these templates are based.
void Enable(int i)
Enables the template at the passed index.
void EnableAll()
Enables all templates in this list.
Encapsulates a value-data entry within one registration key.
const uint8 * GetData() const
Returns the data associated with this value.
TRegValue(const TRegKey &key, LPCTSTR name)
Creates a registry value object from the specified registry key and name.
long Delete()
Removes the value from its associated key, and clears the state of this object.
TRegValue & operator=(uint32 value)
Forwards to Set (uint32).
long Set(uint32 type, const uint8 *data, uint32 dataSize)
Sets the data associated with this value.
Iterator for walking through the values of a key.
int Current() const
Returns the index to the current value.
static void Update(TRegKey &baseKey, tistream &in)
Writes lines to registry.
static int Unregister(TRegList ®Info, const TUnregParams *params, const TRegItem *overrides=nullptr)
Unregisters entries given a reglist.
static int Validate(TRegKey &baseKey, tistream &in)
Returns number of mismatched entries.
Thrown for errors within the Registry classes.
auto GetErrorCode() const -> long
Object Windows Library (OWLNext Core).
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
auto to_tstring(const T &v) -> tstring
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
Various types of smart pointer templatized classes.
General Registry access & registration implementation TRegKey, TRegValue, TRegKeyIterator,...
const tchar * Translate(TLangId lang)
translate string
A single registration list entry.
TLocaleString Value
Localizable value for parameter or subkey.
const char * Key
Non-localized parameter or registry subkey.
Data structure returned by QueryInfo.
LPCTSTR Name
Name of param.
TRegKey * BaseKey
Key that that the param is based upon.
Definition of TSystem, a system information provider class.
#define GetExceptionCode()