48 if ((pszPath[0] ==
_T(
'\\')) && (pszPath[1] ==
_T(
'\\')))
51 while (*pszPath && (*pszPath !=
_T(
'\\')))
93 if (*pszRelativePath ==
_T(
'\\'))
97 const TCHAR *pszSeps =
_T(
"\\");
107 _tcscpy(pszBuffer,pszRelativePath);
113 if (pszBuffer[
size-1] ==
_T(
'\\'))
114 pszBuffer[--
size] = 0;
117 if (*pszBuffer ==
_T(
'\"') && (psz =
_tcschr(pszBuffer+1,
_T(
'\"'))) &&
size_t(psz-pszBuffer) ==
size-1)
128 if ((!pszNewKey)&&((*pszRelativePath !=
_T(
'\\'))||(*(pszRelativePath+1) != 0)))
177 if (pszMachineName ==
NULL)
189 while ((*pszMachineName)&&(*pszMachineName ==
_T(
'\\')))
196 if (!pszNewMachineName)
247 SetError(
_T(
"A key \"%s\" already exists."),pszKeyName);
253 SetError(
_T(
"Cannot create key : %s%s\nError %d (%s)\n"),
276 DWORD dwMaxSubkeyNameLength;
280 SetError(
_T(
"Cannot delete subkeys(s) of key %s.\nRequesting info about key failed.\nError %d (%s)\n"),
285 TCHAR *pszSubkeyName =
new (std::nothrow)
TCHAR [dwMaxSubkeyNameLength];
308 SetError(
_T(
"Cannot delete the %s subkey of key %s.\nError %d (%s)\n"),
313 blnKeyDeleted =
TRUE;
321 SetError(
_T(
"Cannot delete subkeys(s) of key %s.\nSubkey enumeration failed.\nError %d (%s)\n"),
327 SetError(
_T(
"The key %s has no subkeys that match %s pattern.\n"),rKey.
GetKeyName(),pszKeyPattern);
329 return blnKeyDeleted;
337 return _T(
"Access denied");
339 return _T(
"The system cannot find the key specified");
341 return _T(
"Internal error");
343 return _T(
"Out of memory");
345 return _T(
"Unknown error");
396 if (!pszSubkeyNameBuffer)
398 SetError(
_T(
"Cannot open key : %s%s\nError %d (%s)\n"),
402 _tcscpy(pszSubkeyNameBuffer,pszSubkeyName);
403 if (
size && (pszSubkeyName[0] ==
_T(
'\"')) && (pszSubkeyName[
size-1] ==
_T(
'\"')))
405 pszSubkeyNameBuffer[
size-1] = 0;
406 pszSubkeyName = pszSubkeyNameBuffer+1;
411 delete[] pszSubkeyNameBuffer;
415 if (
_tcscmp(pszSubkeyName,
_T(
"..")) == 0)
422 SetError(
_T(
"Cannot open key. The root is not child.\n"));
423 delete[] pszSubkeyNameBuffer;
431 delete[] pszSubkeyNameBuffer;
437 delete[] pszSubkeyNameBuffer;
444 SetError(
_T(
"Cannot open key : %s%s\nError %d (%s)\n"),
446 delete[] pszSubkeyNameBuffer;
453 delete[] pszSubkeyNameBuffer;
459 delete[] pszSubkeyNameBuffer;
473 SetError(
_T(
"Cannot open key : %s%s\nError %u (%s)\n"),
480 DWORD dwMaxSubkeyNameLength;
485 pszSubkeyNameCaseUpdated =
new (std::nothrow)
TCHAR [dwMaxSubkeyNameLength];
488 if (
_tcsicmp(pszSubkeyNameCaseUpdated, pszSubkeyName) == 0)
493 delete[] pszSubkeyNameCaseUpdated;
494 pszSubkeyNameCaseUpdated =
NULL;
501 if (pszSubkeyNameCaseUpdated)
507 SetError(
_T(
"Cannot open key : %s%s\nError %d (%s)\n"),
515 delete[] pszSubkeyNameCaseUpdated;
523 SetError(
_T(
"Cannot open key : %s%s\nError %d (%s)\n"),
526 SetError(
_T(
"Cannot open key : %s%s\nUnknown error \n"),
536 if (pszSubkeyNameCaseUpdated)
537 delete[] pszSubkeyNameCaseUpdated;
581 if (pszKeyName ==
NULL)
595 const TCHAR *pszShortKeyName_ = pszKeyName +
size-1;
598 while (pszShortKeyName_ >= pszKeyName)
600 if (*pszShortKeyName_ ==
_T(
'\\'))
606 if (!
size || (*pszShortKeyName_ !=
_T(
'\\')))
614 if (!pszShortKeyName)
621 pszShortKeyName[
size] = 0;
626 delete[] pszShortKeyName;
635 delete[] pszShortKeyName;
640 delete[] pszShortKeyName;
BOOL PatternMatch(const TCHAR *pszPattern, const TCHAR *pszTry)
#define PATTERN_MATCH_ALL
#define COMMAND_NA_ON_ROOT
#define ERROR_MSG_BUFFER_SIZE
#define RegCloseKey(hKey)
LONG GetSubkeyNameMaxLength(DWORD &rdwMaxSubkeyNameLength)
const TCHAR * GetKeyName()
LONG OpenSubkey(REGSAM samDesired, const TCHAR *pszSubkeyName, HKEY &rhKey)
LONG GetNextSubkeyName(DWORD *pdwActualSize=NULL)
LONG DeleteSubkey(const TCHAR *pszPatternSubkeyName)
HRESULT Init(HKEY hKey, const TCHAR *pszPath, const TCHAR *pszKeyName, REGSAM CurrentAccess)
LONG CreateSubkey(REGSAM samDesired, const TCHAR *pszKeyName, HKEY &rhKey, BOOL *pblnOpened=NULL, BOOL blnVolatile=FALSE)
HRESULT InitRoot(const TCHAR *pszMachineName=NULL)
void InitSubkeyEnumeration(TCHAR *pchSubkeyNameBuffer, DWORD dwBufferSize)
const TCHAR * GetErrorDescription(LONG nError)
BOOL InternalChangeCurrentKey(const TCHAR *pszSubkeyName, REGSAM DesiredAccess)
BOOL NewKey(const TCHAR *pszKeyName, const TCHAR *pszPath, BOOL blnVolatile=FALSE)
void SetError(LONG nError)
void AddErrorDescription(const TCHAR *pszFormat,...)
BOOL GetKey(const TCHAR *pchRelativePath, REGSAM DesiredAccess, CRegistryKey &rKey)
void SetErrorCommandNAOnRoot(const TCHAR *pszCommand)
BOOL SetMachineName(LPCTSTR pszMachineName)
BOOL InternalGetSubkey(const TCHAR *pszSubkeyName, REGSAM DesiredAccess, CRegistryKey &rKey)
const TCHAR * GetCurrentPath() const
class CRegistryTree::CNode m_Root
const TCHAR * GetLastErrorDescription()
BOOL ChangeCurrentKey(const TCHAR *pchRelativePath)
BOOL DeleteSubkeys(const TCHAR *pszKeyPattern, const TCHAR *pszPath, BOOL blnRecursive=FALSE)
TCHAR m_ErrorMsg[ERROR_MSG_BUFFER_SIZE+1]
#define ERROR_NO_MORE_ITEMS
#define ERROR_ACCESS_DENIED
#define memcpy(s1, s2, n)
#define ERROR_FILE_NOT_FOUND
#define KEY_ENUMERATE_SUB_KEYS
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
#define ERROR_INTERNAL_ERROR