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