7 #ifndef _INC_cRegKeyX_H
8 #define _INC_cRegKeyX_H
13 #include "../GrayLibBase.h"
40 typedef cRegKey SUPER_t;
43 static const cRegKeyName k_aNames[];
45 cRegKeyX(HKEY hKey = HKEY_LOCAL_MACHINE) noexcept
57 const FILECHAR_t* get_NameBase() const noexcept
59 return GetNameBase(get_HKey());
62 HRESULT OpenCreate(HKEY hKeyBase,
const FILECHAR_t* pszSubKey, DWORD dwOptions = REG_OPTION_NON_VOLATILE,
63 REGSAM samDesired = KEY_ALL_ACCESS, SECURITY_ATTRIBUTES* pSa =
nullptr);
77 if (pszValue ==
nullptr)
86 LSTATUS lRet =
_FNF(::RegSetValueEx)(get_HKey(), pszSubKey, 0, REG_SZ, (
const BYTE*)pszValue, dwLenData);
88 LSTATUS lRet =
_FNF(::RegSetValue)(get_HKey(), pszSubKey, REG_SZ, pszValue, dwLenData);
93 #if (_MSC_VER>=1300) || defined(__GNUC__)
99 HRESULT SetValueInit(
const cRegKeyInit& val);
108 ASSERT(pszValue !=
nullptr);
109 return SetValue(lpszValueName, REG_SZ, pszValue,
StrT::Len(pszValue) + 1);
120 ASSERT(pszValue !=
nullptr);
121 return SetValue(pszKey, REG_EXPAND_SZ, pszValue,
StrT::Len(pszValue) + 1);
127 return SetValueDWORD(pszKey, iValue);
130 cStringT<FILECHAR_t> GetValueString(
const FILECHAR_t* pszKey,
const FILECHAR_t* pszValDefault =
_FN(
""),
bool bExp =
false)
133 HRESULT hRes = QueryValueStr(pszKey, szTmp,
STRMAX(szTmp), bExp);
138 if (pszValDefault ==
nullptr)
142 return cStringT<FILECHAR_t>(pszValDefault);
144 int GetValueInt(
const FILECHAR_t* pszKey,
int iValDefault)
148 HRESULT hRes = QueryValueDWORD(pszKey, dwValue);
158 static bool GRAYCALL MakeValueDWORD(OUT DWORD& rdwValue, DWORD dwType,
const void* pData, DWORD dwDataSize);
#define _FN(x)
like _T(x) macro for static text file names.
Definition: FileName.h:23
#define _FNF(c)
_WIN32 name has a A or W for UTF8 or UNICODE
Definition: FileName.h:24
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define SUCCEEDED(x)
Definition: HResult.h:29
#define STRMAX(x)
Get Max size of static string space. minus the '\0' terminator character.
Definition: StrConst.h:33
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
static HRESULT FromWin32(DWORD dwWin32Code) noexcept
Definition: HResult.h:198
LONG LSTATUS
AKA error_status_t. FACILITY_WIN32 codes returned from RegCreateKeyEx() etc. Maybe NOT GetLastError()...
Definition: HResult.h:74
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
cStringT< GChar_t > cString
Definition: cString.h:636
static const StrLen_t k_LEN_MAX
arbitrary max size for Format() etc. NOTE: _MSC_VER says stack frame should be at least 16384
Definition: StrT.h:75
static StrLen_t Len(const TYPE *pszStr) noexcept