ReactOS 0.4.15-dev-5672-gf73ac17
RegistryTree.h
Go to the documentation of this file.
1//
2// RegistryTree.h: interface for the CRegistryTree class.
3//
5
6#if !defined(REGISTRYTREE_H__239A6461_70F2_11D3_9085_204C4F4F5020__INCLUDED_)
7#define REGISTRYTREE_H__239A6461_70F2_11D3_9085_204C4F4F5020__INCLUDED_
8
9#include "RegistryKey.h"
10
11// Max size of error description.
12#define ERROR_MSG_BUFFER_SIZE 1024
13
15{
16public:
17 // Constructor
18 //
19 // Parameters:
20 // nMaxPathSize - size in characters of longest path including terminating NULL char
22
23 // Destructor
24 virtual ~CRegistryTree();
25
26 // Call this function after fail of this class method.
27 //
28 // Return value:
29 // Pointer to buffer containing description of last error.
30 // return value is valid until next method of this class is called.
32
33 // Call this function to get string representation (path) of current key.
34 //
35 // Return value:
36 // Pointer to buffer containing current key path. The pointer is valid until next call to this objet method.
37 const TCHAR * GetCurrentPath() const;
38
39 // Call this function to check if current key is the root key.
40 //
41 // Return value:
42 // FALSE - current key is not the root key.
43 // TRUE - current key is the root key.
45
46 // Call this function to change the current key.
47 //
48 // Parameters:
49 // pchRelativePath - relative path to target key.
50 //
51 // Return value:
52 // TRUE - current key changed successfully.
53 // FALSE - failed to change current key. Call GetLastErrorDescription() to get error description.
54 BOOL ChangeCurrentKey(const TCHAR *pchRelativePath);
55
56 // Call this function to obtain key at relative path and opened with desired access.
57 //
58 // Parametes:
59 // pchRelativePath - path to key to be opened.
60 // DesiredAccess - desired access to key.
61 // rKey - reference to variable that receives pointer to key. Caller must free object with delete operator, when object is not longer needed.
62 //
63 // Return value:
64 // TRUE - key opened successfully.
65 // FALSE - failed to open desired key path size. Call GetLastErrorDescription() to get error description.
66 BOOL GetKey(const TCHAR *pchRelativePath, REGSAM DesiredAccess, CRegistryKey& rKey);
67
68 // Call this function to delete key subkeys.
69 //
70 // Parameters:
71 // pszKeyPattern - pattern to specifying which subkeys to delete.
72 // pszPath - path to key which subkeys will be deleted.
73 // blnRecursive - if FALSE and particular subkey has subkeys, it will not be deleted.
74 //
75 // Return value:
76 // TRUE - key opened successfully.
77 // FALSE - error. Call GetLastErrorDescription() to get error description.
78 BOOL DeleteSubkeys(const TCHAR *pszKeyPattern, const TCHAR *pszPath, BOOL blnRecursive = FALSE);
79
80 BOOL NewKey(const TCHAR *pszKeyName, const TCHAR *pszPath, BOOL blnVolatile = FALSE);
81
82 BOOL SetMachineName(LPCTSTR pszMachineName);
83
84// Internal methods
85private:
87
88 // returns description of error value returned by RegXXXX functions in advapi32.
89 const TCHAR *GetErrorDescription(LONG nError);
90
91 void SetError(LONG nError);
92 void SetError(const TCHAR *pszFormat, ...);
93 void SetErrorCommandNAOnRoot(const TCHAR *pszCommand);
94 void SetInternalError();
95 void AddErrorDescription(const TCHAR *pszFormat, ...);
96
98 BOOL InternalGetSubkey(const TCHAR *pszSubkeyName, REGSAM DesiredAccess, CRegistryKey& rKey);
99 void GotoRoot();
100 BOOL DeleteSubkeys(CRegistryKey& rKey, const TCHAR *pszKeyPattern, BOOL blnRecursive);
101
102private:
103 class CNode
104 {
105 public:
109
110 CNode *m_pCurrentKey; // The current key.
111 TCHAR m_ErrorMsg[ERROR_MSG_BUFFER_SIZE+1]; // Last error description buffer.
112 LPTSTR m_pszMachineName; // Pointer to buffer containing machine name with leading backslashes. NULL if local.
113};
114
115#endif // !defined(REGISTRYTREE_H__239A6461_70F2_11D3_9085_204C4F4F5020__INCLUDED_)
CRegistryTree Tree
#define ERROR_MSG_BUFFER_SIZE
Definition: RegistryTree.h:12
CRegistryKey m_Key
Definition: RegistryTree.h:107
virtual ~CRegistryTree()
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)
CNode * m_pCurrentKey
Definition: RegistryTree.h:110
void SetErrorCommandNAOnRoot(const TCHAR *pszCommand)
BOOL SetMachineName(LPCTSTR pszMachineName)
BOOL InternalGetSubkey(const TCHAR *pszSubkeyName, REGSAM DesiredAccess, CRegistryKey &rKey)
const TCHAR * GetCurrentPath() const
BOOL IsCurrentRoot()
class CRegistryTree::CNode m_Root
void SetInternalError()
LPTSTR m_pszMachineName
Definition: RegistryTree.h:112
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]
Definition: RegistryTree.h:111
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
ACCESS_MASK REGSAM
Definition: winreg.h:69
char TCHAR
Definition: xmlstorage.h:189
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
CHAR * LPTSTR
Definition: xmlstorage.h:192