1 /* $Id: RegistryTree.h 15091 2005-05-07 21:24:31Z sedwards $ */
3 // RegistryTree.h: interface for the CRegistryTree class.
5 //////////////////////////////////////////////////////////////////////
7 #if !defined(REGISTRYTREE_H__239A6461_70F2_11D3_9085_204C4F4F5020__INCLUDED_)
8 #define REGISTRYTREE_H__239A6461_70F2_11D3_9085_204C4F4F5020__INCLUDED_
10 #include "RegistryKey.h"
12 // Max size of error description.
13 #define ERROR_MSG_BUFFER_SIZE 1024
21 // nMaxPathSize - size in characters of longest path including terminating NULL char
25 virtual ~CRegistryTree();
27 // Call this function after fail of this class method.
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();
34 // Call this function to get string representation (path) of current key.
37 // Pointer to buffer containing current key path. The pointer is valid until next call to this objet method.
38 const TCHAR
* GetCurrentPath() const;
40 // Call this function to check if current key is the root key.
43 // FALSE - current key is not the root key.
44 // TRUE - current key is the root key.
47 // Call this function to change the current key.
50 // pchRelativePath - relative path to target key.
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
);
57 // Call this function to obtain key at relative path and opened with desired access.
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.
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
);
69 // Call this function to delete key subkeys.
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.
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
);
81 BOOL
NewKey(const TCHAR
*pszKeyName
, const TCHAR
*pszPath
, BOOL blnVolatile
= FALSE
);
83 BOOL
SetMachineName(LPCTSTR pszMachineName
);
87 CRegistryTree(const CRegistryTree
& Tree
);
89 // returns description of error value returned by RegXXXX functions in advapi32.
90 const TCHAR
*GetErrorDescription(LONG nError
);
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
, ...);
98 BOOL
InternalChangeCurrentKey(const TCHAR
*pszSubkeyName
, REGSAM DesiredAccess
);
99 BOOL
InternalGetSubkey(const TCHAR
*pszSubkeyName
, REGSAM DesiredAccess
, CRegistryKey
& rKey
);
101 BOOL
DeleteSubkeys(CRegistryKey
& rKey
, const TCHAR
*pszKeyPattern
, BOOL blnRecursive
);
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.
116 #endif // !defined(REGISTRYTREE_H__239A6461_70F2_11D3_9085_204C4F4F5020__INCLUDED_)