ReactOS  0.4.15-dev-3193-g74513a7
ATL::CRegKey Class Reference

#include <atlbase.h>

Collaboration diagram for ATL::CRegKey:

Public Member Functions

 CRegKey () throw ()
 
 CRegKey (CRegKey &key) throw ()
 
 CRegKey (HKEY hKey) throw ()
 
 ~CRegKey () throw ()
 
void Attach (HKEY hKey) throw ()
 
LONG Close () throw ()
 
HKEY Detach () throw ()
 
LONG Open (HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) throw ()
 
LONG Create (HKEY hKeyParent, LPCTSTR lpszKeyName, LPTSTR lpszClass=REG_NONE, DWORD dwOptions=REG_OPTION_NON_VOLATILE, REGSAM samDesired=KEY_READ|KEY_WRITE, LPSECURITY_ATTRIBUTES lpSecAttr=NULL, LPDWORD lpdwDisposition=NULL) throw ()
 
LONG QueryValue (LPCTSTR pszValueName, DWORD *pdwType, void *pData, ULONG *pnBytes) throw ()
 
LONG QueryDWORDValue (LPCTSTR pszValueName, DWORD &dwValue) throw ()
 
LONG QueryBinaryValue (LPCTSTR pszValueName, void *pValue, ULONG *pnBytes) throw ()
 
LONG QueryStringValue (LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) throw ()
 
LONG QueryGUIDValue (LPCTSTR pszValueName, GUID &guidValue) throw ()
 
LONG QueryQWORDValue (LPCTSTR pszValueName, ULONGLONG &qwValue) throw ()
 
LONG QueryMultiStringValue (LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) throw ()
 
LONG SetValue (LPCTSTR pszValueName, DWORD dwType, const void *pValue, ULONG nBytes) throw ()
 
LONG SetDWORDValue (LPCTSTR pszValueName, DWORD dwValue) throw ()
 
LONG SetStringValue (LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ) throw ()
 
LONG SetGUIDValue (LPCTSTR pszValueName, REFGUID guidValue) throw ()
 
LONG SetBinaryValue (LPCTSTR pszValueName, const void *pValue, ULONG nBytes) throw ()
 
LONG SetMultiStringValue (LPCTSTR pszValueName, LPCTSTR pszValue) throw ()
 
LONG SetQWORDValue (LPCTSTR pszValueName, ULONGLONG qwValue) throw ()
 
LONG NotifyChangeKeyValue (BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL bAsync=TRUE) throw ()
 
LONG Flush () throw ()
 
LONG SetKeyValue (LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName=NULL) throw ()
 
LONG DeleteValue (LPCTSTR lpszValue) throw ()
 
LONG DeleteSubKey (LPCTSTR lpszSubKey) throw ()
 
LONG RecurseDeleteKey (LPCTSTR lpszKey) throw ()
 
LONG EnumKey (DWORD iIndex, LPTSTR pszName, LPDWORD pnNameLength, FILETIME *pftLastWriteTime=NULL) throw ()
 
LONG GetKeySecurity (SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd, LPDWORD pnBytes) throw ()
 
LONG SetKeySecurity (SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd) throw ()
 
 operator HKEY () const throw ()
 
CRegKeyoperator= (CRegKey &key) throw ()
 

Static Public Member Functions

static LONG WINAPI SetValue (HKEY hKeyParent, LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName=NULL)
 

Public Attributes

HKEY m_hKey
 

Static Protected Member Functions

static ULONG _GetMultiStringSize (LPCTSTR pszz)
 
static LONG _DoDeleteKeyTree (HKEY hParentKey, LPCTSTR lpszKey)
 

Detailed Description

Definition at line 1010 of file atlbase.h.

Constructor & Destructor Documentation

◆ CRegKey() [1/3]

ATL::CRegKey::CRegKey ( )
throw (
)
inline

Definition at line 1021 of file atlbase.h.

1022  : m_hKey(NULL)
1023  {
1024  }
HKEY m_hKey
Definition: atlbase.h:1013
#define NULL
Definition: types.h:112

◆ CRegKey() [2/3]

ATL::CRegKey::CRegKey ( CRegKey key)
throw (
)
inline

Definition at line 1026 of file atlbase.h.

1027  : m_hKey(key.Detach())
1028  {
1029  }
HKEY m_hKey
Definition: atlbase.h:1013
Definition: path.c:41

◆ CRegKey() [3/3]

ATL::CRegKey::CRegKey ( HKEY  hKey)
throw (
)
inlineexplicit

Definition at line 1031 of file atlbase.h.

1032  : m_hKey(hKey)
1033  {
1034  }
HKEY m_hKey
Definition: atlbase.h:1013
FxAutoRegKey hKey

◆ ~CRegKey()

ATL::CRegKey::~CRegKey ( )
throw (
)
inline

Definition at line 1044 of file atlbase.h.

1045  {
1046  Close();
1047  }
LONG Close()
Definition: atlbase.h:1054

Member Function Documentation

◆ _DoDeleteKeyTree()

static LONG ATL::CRegKey::_DoDeleteKeyTree ( HKEY  hParentKey,
LPCTSTR  lpszKey 
)
inlinestaticprotected

Definition at line 1388 of file atlbase.h.

1389  {
1390  ATLASSERT(hParentKey);
1391  ATLASSERT(lpszKey);
1392 
1393  // open the key
1394  CRegKey key;
1395  LONG ret = key.Open(hParentKey, lpszKey);
1396  if (ret != ERROR_SUCCESS)
1397  {
1398  return ret; // failure
1399  }
1400 
1401  // get the longest length of subkey names
1402  DWORD NameMax;
1403  ret = ::RegQueryInfoKey(key, NULL, NULL, NULL, NULL, &NameMax, NULL,
1404  NULL, NULL, NULL, NULL, NULL);
1405  if (ret != ERROR_SUCCESS)
1406  {
1407  return ret; // failure
1408  }
1409  ++NameMax; // for NUL
1410 
1411  // allocate the string buffer for names if necessary
1412  TCHAR szNameBuf[MAX_PATH], *pszName;
1413  if (NameMax > MAX_PATH)
1414  {
1415  pszName = (TCHAR *)malloc(NameMax * sizeof(TCHAR));
1416  ATLASSERT(pszName);
1417  if (pszName == NULL)
1418  {
1419  return ERROR_OUTOFMEMORY; // failure
1420  }
1421  }
1422  else
1423  {
1424  NameMax = MAX_PATH;
1425  pszName = szNameBuf;
1426  }
1427 
1428  // enumerate every subkey and delete
1429  for (;;)
1430  {
1431  DWORD Count = NameMax;
1432  ret = key.EnumKey(0, pszName, &Count);
1433  if (ret != ERROR_SUCCESS)
1434  {
1435  if (ret == ERROR_NO_MORE_ITEMS)
1436  ret = ERROR_SUCCESS;
1437  break;
1438  }
1439 
1440  ret = CRegKey::_DoDeleteKeyTree(key, pszName);
1441  if (ret != ERROR_SUCCESS)
1442  break;
1443  }
1444 
1445  // close key
1446  key.Close();
1447 
1448  // delete the subkey
1449  if (ret == ERROR_SUCCESS)
1450  ret = ::RegDeleteKey(hParentKey, lpszKey);
1451 
1452  // delete the buffer if any
1453  if (pszName != szNameBuf)
1454  free(pszName);
1455 
1456  return ret;
1457  }
#define RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define free
Definition: debug_ros.c:5
long LONG
Definition: pedump.c:60
char TCHAR
Definition: xmlstorage.h:189
int Count
Definition: noreturn.cpp:7
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
HKEY key
Definition: reg.c:42
#define NULL
Definition: types.h:112
#define RegDeleteKey
Definition: winreg.h:502
#define malloc
Definition: debug_ros.c:4
static LONG _DoDeleteKeyTree(HKEY hParentKey, LPCTSTR lpszKey)
Definition: atlbase.h:1388
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
Definition: path.c:41

Referenced by RecurseDeleteKey().

◆ _GetMultiStringSize()

static ULONG ATL::CRegKey::_GetMultiStringSize ( LPCTSTR  pszz)
inlinestaticprotected

Definition at line 1373 of file atlbase.h.

1374  {
1375  size_t count = 0;
1376  do
1377  {
1378  size_t len = _tcslen(pszz);
1379  count += len + 1;
1380  pszz += len + 1;
1381  } while (*pszz != TEXT('\0'));
1382  ++count;
1383  ATLASSERT(count * sizeof(TCHAR) <= ULONG_MAX);
1384  return (ULONG)count * sizeof(TCHAR);
1385  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
GLuint GLuint GLsizei count
Definition: gl.h:1545
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
char TCHAR
Definition: xmlstorage.h:189
GLenum GLsizei len
Definition: glext.h:6722
#define TEXT(s)
Definition: k32.h:26
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_MAX
Definition: limits.h:44

Referenced by SetMultiStringValue().

◆ Attach()

void ATL::CRegKey::Attach ( HKEY  hKey)
throw (
)
inline

Definition at line 1049 of file atlbase.h.

1050  {
1051  m_hKey = hKey;
1052  }
HKEY m_hKey
Definition: atlbase.h:1013
FxAutoRegKey hKey

Referenced by operator=().

◆ Close()

LONG ATL::CRegKey::Close ( void  )
throw (
)
inline

Definition at line 1054 of file atlbase.h.

1055  {
1056  if (m_hKey)
1057  {
1058  HKEY hKey = Detach();
1060  }
1061  return ERROR_SUCCESS;
1062  }
#define ERROR_SUCCESS
Definition: deptool.c:10
HKEY m_hKey
Definition: atlbase.h:1013
HKEY Detach()
Definition: atlbase.h:1064
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
FxAutoRegKey hKey

Referenced by Create(), Open(), operator=(), and ~CRegKey().

◆ Create()

LONG ATL::CRegKey::Create ( HKEY  hKeyParent,
LPCTSTR  lpszKeyName,
LPTSTR  lpszClass = REG_NONE,
DWORD  dwOptions = REG_OPTION_NON_VOLATILE,
REGSAM  samDesired = KEY_READ | KEY_WRITE,
LPSECURITY_ATTRIBUTES  lpSecAttr = NULL,
LPDWORD  lpdwDisposition = NULL 
)
throw (
)
inline

Definition at line 1092 of file atlbase.h.

1098  {
1099  ATLASSERT(hKeyParent);
1100  ATLASSERT(lpszKeyName);
1101 
1102  HKEY hKey = NULL;
1103  LONG lRes = ::RegCreateKeyEx(hKeyParent, lpszKeyName, 0, lpszClass,
1104  dwOptions, samDesired, lpSecAttr, &hKey,
1105  lpdwDisposition);
1106  if (lRes != ERROR_SUCCESS)
1107  {
1108  samDesired |= KEY_WOW64_64KEY;
1109  lRes = ::RegCreateKeyEx(hKeyParent, lpszKeyName, 0, lpszClass,
1110  dwOptions, samDesired, lpSecAttr, &hKey,
1111  lpdwDisposition);
1112  }
1113  if (lRes == ERROR_SUCCESS)
1114  {
1115  Close();
1116  m_hKey = hKey;
1117  }
1118  return lRes;
1119  }
DWORD dwOptions
Definition: solitaire.cpp:24
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
LONG Close()
Definition: atlbase.h:1054
HKEY m_hKey
Definition: atlbase.h:1013
long LONG
Definition: pedump.c:60
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define RegCreateKeyEx
Definition: winreg.h:501

Referenced by CACLCustomMRU::Initialize(), SaveSettings(), and RegistrySettings::Store().

◆ DeleteSubKey()

LONG ATL::CRegKey::DeleteSubKey ( LPCTSTR  lpszSubKey)
throw (
)
inline

Definition at line 1317 of file atlbase.h.

1318  {
1319  ATLASSERT(m_hKey);
1320  ATLASSERT(lpszSubKey);
1321  return ::RegDeleteKey(m_hKey, lpszSubKey);
1322  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
#define RegDeleteKey
Definition: winreg.h:502

Referenced by Cleanup_Testdata().

◆ DeleteValue()

LONG ATL::CRegKey::DeleteValue ( LPCTSTR  lpszValue)
throw (
)
inline

Definition at line 1311 of file atlbase.h.

1312  {
1313  ATLASSERT(m_hKey);
1314  return ::RegDeleteValue(m_hKey, lpszValue);
1315  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
#define RegDeleteValue
Definition: winreg.h:508

◆ Detach()

HKEY ATL::CRegKey::Detach ( )
throw (
)
inline

Definition at line 1064 of file atlbase.h.

1065  {
1066  HKEY hKey = m_hKey;
1067  m_hKey = NULL;
1068  return hKey;
1069  }
HKEY m_hKey
Definition: atlbase.h:1013
FxAutoRegKey hKey
#define NULL
Definition: types.h:112

Referenced by Close().

◆ EnumKey()

LONG ATL::CRegKey::EnumKey ( DWORD  iIndex,
LPTSTR  pszName,
LPDWORD  pnNameLength,
FILETIME pftLastWriteTime = NULL 
)
throw (
)
inline

Definition at line 1331 of file atlbase.h.

1333  {
1334  ATLASSERT(m_hKey);
1335  LONG ret = ::RegEnumKeyEx(m_hKey, iIndex, pszName, pnNameLength, NULL,
1336  NULL, NULL, pftLastWriteTime);
1337  return ret;
1338  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
long LONG
Definition: pedump.c:60
int ret
#define RegEnumKeyEx
Definition: winreg.h:510
#define NULL
Definition: types.h:112

◆ Flush()

LONG ATL::CRegKey::Flush ( )
throw (
)
inline

Definition at line 1280 of file atlbase.h.

1281  {
1282  ATLASSERT(m_hKey);
1284  return ret;
1285  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
HKEY m_hKey
Definition: atlbase.h:1013
long LONG
Definition: pedump.c:60
int ret

◆ GetKeySecurity()

LONG ATL::CRegKey::GetKeySecurity ( SECURITY_INFORMATION  si,
PSECURITY_DESCRIPTOR  psd,
LPDWORD  pnBytes 
)
throw (
)
inline

Definition at line 1340 of file atlbase.h.

1342  {
1343  ATLASSERT(m_hKey);
1344  LONG ret = ::RegGetKeySecurity(m_hKey, si, psd, pnBytes);
1345  return ret;
1346  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
long LONG
Definition: pedump.c:60
LONG WINAPI RegGetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, LPDWORD lpcbSecurityDescriptor)
Definition: reg.c:3010
int ret

◆ NotifyChangeKeyValue()

LONG ATL::CRegKey::NotifyChangeKeyValue ( BOOL  bWatchSubtree,
DWORD  dwNotifyFilter,
HANDLE  hEvent,
BOOL  bAsync = TRUE 
)
throw (
)
inline

Definition at line 1271 of file atlbase.h.

1273  {
1274  ATLASSERT(m_hKey);
1275  LONG ret = ::RegNotifyChangeKeyValue(m_hKey, bWatchSubtree,
1276  dwNotifyFilter, hEvent, bAsync);
1277  return ret;
1278  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
static HANDLE hEvent
Definition: comm.c:54
long LONG
Definition: pedump.c:60
int ret
LONG WINAPI RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL fAsynchronous)
Definition: reg.c:3175

◆ Open()

LONG ATL::CRegKey::Open ( HKEY  hKeyParent,
LPCTSTR  lpszKeyName,
REGSAM  samDesired = KEY_READ | KEY_WRITE 
)
throw (
)
inline

Definition at line 1071 of file atlbase.h.

1073  {
1074  ATLASSERT(hKeyParent);
1075  ATLASSERT(lpszKeyName);
1076 
1077  HKEY hKey = NULL;
1078  LONG lRes = ::RegOpenKeyEx(hKeyParent, lpszKeyName, 0, samDesired, &hKey);
1079  if (lRes != ERROR_SUCCESS)
1080  {
1081  samDesired |= KEY_WOW64_64KEY;
1082  lRes = ::RegOpenKeyEx(hKeyParent, lpszKeyName, 0, samDesired, &hKey);
1083  }
1084  if (lRes == ERROR_SUCCESS)
1085  {
1086  Close();
1087  m_hKey = hKey;
1088  }
1089  return lRes;
1090  }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
LONG Close()
Definition: atlbase.h:1054
HKEY m_hKey
Definition: atlbase.h:1013
long LONG
Definition: pedump.c:60
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
#define RegOpenKeyEx
Definition: winreg.h:520
FxAutoRegKey hKey
#define NULL
Definition: types.h:112

Referenced by Cleanup_Testdata(), CFontExt::Drop(), RegistrySettings::Load(), LoadSettings(), and RegistrySettings::SetWallpaper().

◆ operator HKEY()

ATL::CRegKey::operator HKEY ( ) const
throw (
)
inline

Definition at line 1356 of file atlbase.h.

1357  {
1358  return m_hKey;
1359  }
HKEY m_hKey
Definition: atlbase.h:1013

◆ operator=()

CRegKey& ATL::CRegKey::operator= ( CRegKey key)
throw (
)
inline

Definition at line 1361 of file atlbase.h.

1362  {
1363  if (m_hKey != key.m_hKey)
1364  {
1365  Close();
1366  Attach(key.Detach());
1367  }
1368  return *this;
1369  }
LONG Close()
Definition: atlbase.h:1054
HKEY m_hKey
Definition: atlbase.h:1013
void Attach(HKEY hKey)
Definition: atlbase.h:1049
Definition: path.c:41

◆ QueryBinaryValue()

LONG ATL::CRegKey::QueryBinaryValue ( LPCTSTR  pszValueName,
void pValue,
ULONG pnBytes 
)
throw (
)
inline

Definition at line 1139 of file atlbase.h.

1140  {
1141  DWORD type = 0;
1142  LONG lRet = QueryValue(pszValueName, &type, pValue, pnBytes);
1143 
1144  if (lRet == ERROR_SUCCESS && type != REG_BINARY)
1145  lRet = ERROR_INVALID_DATA;
1146 
1147  return lRet;
1148  }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_BINARY
Definition: nt_native.h:1496
PWCHAR pValue
long LONG
Definition: pedump.c:60
LONG QueryValue(LPCTSTR pszValueName, DWORD *pdwType, void *pData, ULONG *pnBytes)
Definition: atlbase.h:1121
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_INVALID_DATA
Definition: winerror.h:116
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

◆ QueryDWORDValue()

LONG ATL::CRegKey::QueryDWORDValue ( LPCTSTR  pszValueName,
DWORD dwValue 
)
throw (
)
inline

Definition at line 1127 of file atlbase.h.

1128  {
1129  ULONG size = sizeof(DWORD);
1130  DWORD type = 0;
1131  LONG lRet = QueryValue(pszValueName, &type, &dwValue, &size);
1132 
1133  if (lRet == ERROR_SUCCESS && type != REG_DWORD)
1134  lRet = ERROR_INVALID_DATA;
1135 
1136  return lRet;
1137  }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
LONG QueryValue(LPCTSTR pszValueName, DWORD *pdwType, void *pData, ULONG *pnBytes)
Definition: atlbase.h:1121
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_INVALID_DATA
Definition: winerror.h:116
unsigned int ULONG
Definition: retypes.h:1
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_DWORD
Definition: sdbapi.c:596

◆ QueryGUIDValue()

LONG ATL::CRegKey::QueryGUIDValue ( LPCTSTR  pszValueName,
GUID guidValue 
)
throw (
)
inline

Definition at line 1163 of file atlbase.h.

1164  {
1165  OLECHAR buf[40] = {0};
1166  ULONG nChars = 39;
1167  LONG lRet;
1168 
1169 #ifdef UNICODE
1170  lRet = QueryStringValue(pszValueName, buf, &nChars);
1171 #else
1172  CHAR bufA[40] = {0};
1173  lRet = QueryStringValue(pszValueName, bufA, &nChars);
1174  if (lRet != ERROR_SUCCESS)
1175  return lRet;
1176  if (!::MultiByteToWideChar(CP_THREAD_ACP, 0, bufA, -1, buf, 39))
1177  lRet = ERROR_INVALID_DATA;
1178 #endif
1179  if (lRet != ERROR_SUCCESS)
1180  return lRet;
1181 
1182  if (!SUCCEEDED(::CLSIDFromString(buf, &guidValue)))
1183  return ERROR_INVALID_DATA;
1184 
1185  return lRet;
1186  }
WCHAR OLECHAR
Definition: compat.h:2151
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
long LONG
Definition: pedump.c:60
if SUCCEEDED(hr)
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars)
Definition: atlbase.h:1150
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
unsigned int ULONG
Definition: retypes.h:1
#define CP_THREAD_ACP
Definition: winnls.h:233

◆ QueryMultiStringValue()

LONG ATL::CRegKey::QueryMultiStringValue ( LPCTSTR  pszValueName,
LPTSTR  pszValue,
ULONG pnChars 
)
throw (
)
inline

Definition at line 1200 of file atlbase.h.

1202  {
1203  ULONG size = (*pnChars) * sizeof(TCHAR);
1204  DWORD type;
1205  LONG lRet = QueryValue(pszValueName, &type, pszValue, &size);
1206 
1207  if (lRet == ERROR_SUCCESS && type != REG_MULTI_SZ)
1208  lRet = ERROR_INVALID_DATA;
1209 
1210  *pnChars = size / sizeof(TCHAR);
1211  return lRet;
1212  }
#define ERROR_SUCCESS
Definition: deptool.c:10
long LONG
Definition: pedump.c:60
#define REG_MULTI_SZ
Definition: nt_native.h:1501
LONG QueryValue(LPCTSTR pszValueName, DWORD *pdwType, void *pData, ULONG *pnBytes)
Definition: atlbase.h:1121
char TCHAR
Definition: xmlstorage.h:189
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_INVALID_DATA
Definition: winerror.h:116
unsigned int ULONG
Definition: retypes.h:1
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

◆ QueryQWORDValue()

LONG ATL::CRegKey::QueryQWORDValue ( LPCTSTR  pszValueName,
ULONGLONG qwValue 
)
throw (
)
inline

Definition at line 1188 of file atlbase.h.

1189  {
1190  ULONG size = sizeof(ULONGLONG);
1191  DWORD type = 0;
1192  LONG lRet = QueryValue(pszValueName, &type, &qwValue, &size);
1193 
1194  if (lRet == ERROR_SUCCESS && type != REG_QWORD)
1195  lRet = ERROR_INVALID_DATA;
1196 
1197  return lRet;
1198  }
#define ERROR_SUCCESS
Definition: deptool.c:10
long LONG
Definition: pedump.c:60
LONG QueryValue(LPCTSTR pszValueName, DWORD *pdwType, void *pData, ULONG *pnBytes)
Definition: atlbase.h:1121
GLsizeiptr size
Definition: glext.h:5919
uint64_t ULONGLONG
Definition: typedefs.h:67
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define REG_QWORD
Definition: sdbapi.c:597
unsigned int ULONG
Definition: retypes.h:1
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

◆ QueryStringValue()

LONG ATL::CRegKey::QueryStringValue ( LPCTSTR  pszValueName,
LPTSTR  pszValue,
ULONG pnChars 
)
throw (
)
inline

Definition at line 1150 of file atlbase.h.

1151  {
1152  ULONG size = (*pnChars) * sizeof(TCHAR);
1153  DWORD type = 0;
1154  LONG lRet = QueryValue(pszValueName, &type, pszValue, &size);
1155 
1156  if (lRet == ERROR_SUCCESS && type != REG_SZ && type != REG_EXPAND_SZ)
1157  lRet = ERROR_INVALID_DATA;
1158 
1159  *pnChars = size / sizeof(TCHAR);
1160  return lRet;
1161  }
#define ERROR_SUCCESS
Definition: deptool.c:10
long LONG
Definition: pedump.c:60
LONG QueryValue(LPCTSTR pszValueName, DWORD *pdwType, void *pData, ULONG *pnBytes)
Definition: atlbase.h:1121
char TCHAR
Definition: xmlstorage.h:189
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
unsigned int ULONG
Definition: retypes.h:1
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_SZ
Definition: layer.c:22

Referenced by CACLCustomMRU::LoadMRUList(), and QueryGUIDValue().

◆ QueryValue()

LONG ATL::CRegKey::QueryValue ( LPCTSTR  pszValueName,
DWORD pdwType,
void pData,
ULONG pnBytes 
)
throw (
)
inline

Definition at line 1121 of file atlbase.h.

1122  {
1123  ATLASSERT(m_hKey);
1124  return ::RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, (LPBYTE)pData, pnBytes);
1125  }
#define RegQueryValueEx
Definition: winreg.h:524
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
unsigned char * LPBYTE
Definition: typedefs.h:53
#define NULL
Definition: types.h:112
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by QueryBinaryValue(), QueryDWORDValue(), QueryMultiStringValue(), QueryQWORDValue(), and QueryStringValue().

◆ RecurseDeleteKey()

LONG ATL::CRegKey::RecurseDeleteKey ( LPCTSTR  lpszKey)
throw (
)
inline

Definition at line 1324 of file atlbase.h.

1325  {
1326  ATLASSERT(m_hKey);
1327  ATLASSERT(lpszKey);
1328  return CRegKey::_DoDeleteKeyTree(m_hKey, lpszKey);
1329  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
static LONG _DoDeleteKeyTree(HKEY hParentKey, LPCTSTR lpszKey)
Definition: atlbase.h:1388

◆ SetBinaryValue()

LONG ATL::CRegKey::SetBinaryValue ( LPCTSTR  pszValueName,
const void pValue,
ULONG  nBytes 
)
throw (
)
inline

Definition at line 1254 of file atlbase.h.

1255  {
1256  return SetValue(pszValueName, REG_BINARY, pValue, nBytes);
1257  }
#define REG_BINARY
Definition: nt_native.h:1496
PWCHAR pValue
LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void *pValue, ULONG nBytes)
Definition: atlbase.h:1214

◆ SetDWORDValue()

LONG ATL::CRegKey::SetDWORDValue ( LPCTSTR  pszValueName,
DWORD  dwValue 
)
throw (
)
inline

Definition at line 1220 of file atlbase.h.

1221  {
1222  return SetValue(pszValueName, REG_DWORD, &dwValue, sizeof(DWORD));
1223  }
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_DWORD
Definition: sdbapi.c:596
LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void *pValue, ULONG nBytes)
Definition: atlbase.h:1214

◆ SetGUIDValue()

LONG ATL::CRegKey::SetGUIDValue ( LPCTSTR  pszValueName,
REFGUID  guidValue 
)
throw (
)
inline

Definition at line 1241 of file atlbase.h.

1242  {
1243  OLECHAR buf[40] = {0};
1244  ::StringFromGUID2(guidValue, buf, 39);
1245 #ifdef UNICODE
1246  return SetStringValue(pszValueName, buf);
1247 #else
1248  CHAR bufA[40] = {0};
1249  ::WideCharToMultiByte(CP_THREAD_ACP, 0, buf, -1, bufA, 40, NULL, NULL);
1250  return SetStringValue(pszValueName, bufA);
1251 #endif
1252  }
WCHAR OLECHAR
Definition: compat.h:2151
#define WideCharToMultiByte
Definition: compat.h:111
char CHAR
Definition: xmlstorage.h:175
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
#define NULL
Definition: types.h:112
#define CP_THREAD_ACP
Definition: winnls.h:233
LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType=REG_SZ)
Definition: atlbase.h:1225

◆ SetKeySecurity()

LONG ATL::CRegKey::SetKeySecurity ( SECURITY_INFORMATION  si,
PSECURITY_DESCRIPTOR  psd 
)
throw (
)
inline

Definition at line 1348 of file atlbase.h.

1350  {
1351  ATLASSERT(m_hKey);
1352  LONG ret = ::RegSetKeySecurity(m_hKey, si, psd);
1353  return ret;
1354  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HKEY m_hKey
Definition: atlbase.h:1013
long LONG
Definition: pedump.c:60
LONG WINAPI RegSetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor)
Definition: reg.c:4772
int ret

◆ SetKeyValue()

LONG ATL::CRegKey::SetKeyValue ( LPCTSTR  lpszKeyName,
LPCTSTR  lpszValue,
LPCTSTR  lpszValueName = NULL 
)
throw (
)
inline

Definition at line 1299 of file atlbase.h.

1301  {
1302  CRegKey key;
1303  LONG lRet = key.Create(m_hKey, lpszKeyName);
1304  if (lRet == ERROR_SUCCESS)
1305  {
1306  lRet = key.SetStringValue(lpszValueName, lpszValue);
1307  }
1308  return lRet;
1309  }
#define ERROR_SUCCESS
Definition: deptool.c:10
HKEY m_hKey
Definition: atlbase.h:1013
long LONG
Definition: pedump.c:60
HKEY key
Definition: reg.c:42
Definition: path.c:41

◆ SetMultiStringValue()

LONG ATL::CRegKey::SetMultiStringValue ( LPCTSTR  pszValueName,
LPCTSTR  pszValue 
)
throw (
)
inline

Definition at line 1259 of file atlbase.h.

1260  {
1262  return SetValue(pszValueName, REG_MULTI_SZ, pszValue, dwSize);
1263  }
#define REG_MULTI_SZ
Definition: nt_native.h:1501
static ULONG _GetMultiStringSize(LPCTSTR pszz)
Definition: atlbase.h:1373
unsigned int ULONG
Definition: retypes.h:1
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void *pValue, ULONG nBytes)
Definition: atlbase.h:1214

Referenced by SetStringValue().

◆ SetQWORDValue()

LONG ATL::CRegKey::SetQWORDValue ( LPCTSTR  pszValueName,
ULONGLONG  qwValue 
)
throw (
)
inline

Definition at line 1265 of file atlbase.h.

1266  {
1267  ULONG dwSize = sizeof(ULONGLONG);
1268  return SetValue(pszValueName, REG_QWORD, &qwValue, dwSize);
1269  }
uint64_t ULONGLONG
Definition: typedefs.h:67
#define REG_QWORD
Definition: sdbapi.c:597
unsigned int ULONG
Definition: retypes.h:1
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void *pValue, ULONG nBytes)
Definition: atlbase.h:1214

◆ SetStringValue()

LONG ATL::CRegKey::SetStringValue ( LPCTSTR  pszValueName,
LPCTSTR  pszValue,
DWORD  dwType = REG_SZ 
)
throw (
)
inline

Definition at line 1225 of file atlbase.h.

1226  {
1227  SIZE_T length;
1228  switch (dwType)
1229  {
1230  case REG_SZ:
1231  case REG_EXPAND_SZ:
1232  length = (_tcslen(pszValue) + 1) * sizeof(TCHAR);
1233  return SetValue(pszValueName, dwType, pszValue, length);
1234  case REG_MULTI_SZ:
1235  return SetMultiStringValue(pszValueName, pszValue);
1236  default:
1237  return ERROR_INVALID_DATA;
1238  }
1239  }
LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue)
Definition: atlbase.h:1259
#define REG_MULTI_SZ
Definition: nt_native.h:1501
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
char TCHAR
Definition: xmlstorage.h:189
#define ERROR_INVALID_DATA
Definition: winerror.h:116
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void *pValue, ULONG nBytes)
Definition: atlbase.h:1214
#define REG_SZ
Definition: layer.c:22

Referenced by CACLCustomMRU::PersistMRU(), SetGUIDValue(), RegistrySettings::SetWallpaper(), and RegistrySettings::Store().

◆ SetValue() [1/2]

LONG ATL::CRegKey::SetValue ( LPCTSTR  pszValueName,
DWORD  dwType,
const void pValue,
ULONG  nBytes 
)
throw (
)
inline

Definition at line 1214 of file atlbase.h.

1215  {
1216  ATLASSERT(m_hKey);
1217  return ::RegSetValueEx(m_hKey, pszValueName, 0, dwType, (const BYTE*)pValue, nBytes);
1218  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
PWCHAR pValue
HKEY m_hKey
Definition: atlbase.h:1013
unsigned char BYTE
Definition: xxhash.c:193
#define RegSetValueEx
Definition: winreg.h:533

Referenced by SetBinaryValue(), SetDWORDValue(), SetMultiStringValue(), SetQWORDValue(), and SetStringValue().

◆ SetValue() [2/2]

static LONG WINAPI ATL::CRegKey::SetValue ( HKEY  hKeyParent,
LPCTSTR  lpszKeyName,
LPCTSTR  lpszValue,
LPCTSTR  lpszValueName = NULL 
)
inlinestatic

Definition at line 1287 of file atlbase.h.

1289  {
1290  CRegKey key;
1291  LONG lRet = key.Create(hKeyParent, lpszKeyName);
1292  if (lRet == ERROR_SUCCESS)
1293  {
1294  lRet = key.SetStringValue(lpszValueName, lpszValue);
1295  }
1296  return lRet;
1297  }
#define ERROR_SUCCESS
Definition: deptool.c:10
long LONG
Definition: pedump.c:60
HKEY key
Definition: reg.c:42
Definition: path.c:41

Member Data Documentation

◆ m_hKey


The documentation for this class was generated from the following file: