ReactOS 0.4.15-dev-7924-g5949c20
CShellCommandDeleteKey Class Reference

#include <ShellCommandDeleteKey.h>

Inheritance diagram for CShellCommandDeleteKey:
Collaboration diagram for CShellCommandDeleteKey:

Public Member Functions

 CShellCommandDeleteKey (CRegistryTree &rTree)
 
virtual ~CShellCommandDeleteKey ()
 
virtual BOOL Match (const TCHAR *pchCommand)
 
virtual int Execute (CConsole &rConsole, CArgumentParser &rArguments)
 
virtual const TCHARGetHelpString ()
 
virtual const TCHARGetHelpShortDescriptionString ()
 
- Public Member Functions inherited from CShellCommand
 CShellCommand ()
 
virtual ~CShellCommand ()
 
virtual BOOL Match (const TCHAR *pchCommand)=0
 
virtual int Execute (CConsole &rConsole, CArgumentParser &rArguments)=0
 
virtual const TCHARGetHelpString ()=0
 
virtual const TCHARGetHelpShortDescriptionString ()=0
 

Private Attributes

CRegistryTreem_rTree
 

Detailed Description

Definition at line 12 of file ShellCommandDeleteKey.h.

Constructor & Destructor Documentation

◆ CShellCommandDeleteKey()

CShellCommandDeleteKey::CShellCommandDeleteKey ( CRegistryTree rTree)

Definition at line 37 of file ShellCommandDeleteKey.cpp.

37 :m_rTree(rTree)
38{
39}

◆ ~CShellCommandDeleteKey()

CShellCommandDeleteKey::~CShellCommandDeleteKey ( )
virtual

Definition at line 41 of file ShellCommandDeleteKey.cpp.

42{
43}

Member Function Documentation

◆ Execute()

int CShellCommandDeleteKey::Execute ( CConsole rConsole,
CArgumentParser rArguments 
)
virtual

Implements CShellCommand.

Definition at line 50 of file ShellCommandDeleteKey.cpp.

51{
52 TCHAR *pchKey = NULL, *pchArg;
53
54 BOOL blnHelp = FALSE;
55 BOOL blnExitAfterHelp = FALSE;
56 BOOL blnRecursive = FALSE;
57
58 while((pchArg = rArguments.GetNextArgument()) != NULL)
59 {
60 if ((_tcsicmp(pchArg,_T("/?")) == 0)
61 ||(_tcsicmp(pchArg,_T("-?")) == 0))
62 {
63 blnHelp = TRUE;
64 }
65 else if ((_tcsicmp(pchArg,_T("/s")) == 0)
66 ||(_tcsicmp(pchArg,_T("-s")) == 0))
67 {
68 blnRecursive = TRUE;
69 }
70 else
71 {
72 if (pchKey)
73 {
74 rConsole.Write(_T("Wrong parameter : \""));
75 rConsole.Write(pchArg);
76 rConsole.Write(_T("\"\n\n"));
77 blnHelp = TRUE;
78 }
79 else
80 {
81 pchKey = pchArg;
82 }
83 }
84 }
85
86 if ((!blnHelp) && (!pchKey))
87 {
88 rConsole.Write(_T("Key name not specified !\n\n"));
89 blnExitAfterHelp = TRUE;
90 }
91
92 if (blnHelp)
93 {
94 rConsole.Write(GetHelpString());
95 if (blnExitAfterHelp)
96 return 0;
97 else
98 rConsole.Write(_T("\n"));
99 }
100
101 // search for last key name token
102 TCHAR *pch = pchKey;
103 while(*pch)
104 pch++;
105
106 if (pch > pchKey)
107 pch--;
108
109 while(*pch == _T('\\'))
110 *pch = 0;
111
112 while((pch > pchKey)&&(*pch != _T('\\')))
113 pch--;
114
115 ASSERT(pch >= pchKey);
116
117 const TCHAR *pszPath;
118 TCHAR *pszPattern = pch;
119 if (*pch == _T('\\'))
120 pszPattern++;
121
122 if (pch == pchKey)
123 {
124 pszPath = _T(".");
125 }
126 else
127 {
128 if (pch-1 == pchKey)
129 {
131 return 0;
132 }
133 else
134 {
135 *pch = 0;
136 pszPath = pchKey;
137 }
138 }
139
140 {
141 size_t s = _tcslen(pszPattern);
142 if (s && (pszPattern[0] == _T('\"'))&&(pszPattern[s-1] == _T('\"')))
143 {
144 pszPattern[s-1] = 0;
145 pszPattern++;
146 }
147 }
148
149 if (!m_rTree.DeleteSubkeys(pszPattern,pszPath,blnRecursive))
150 {
151 rConsole.Write(_T("Cannot delete key(s).\n"));
153 }
154 else
155 {
157 }
158
159 return 0;
160}
void InvalidateCompletion()
Definition: Completion.cpp:511
#define COMMAND_NA_ON_ROOT
#define DK_CMD
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
const TCHAR * GetLastErrorDescription()
BOOL DeleteSubkeys(const TCHAR *pszKeyPattern, const TCHAR *pszPath, BOOL blnRecursive=FALSE)
virtual const TCHAR * GetHelpString()
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble s
Definition: gl.h:2039
#define pch(ap)
Definition: match.c:418
#define ASSERT(a)
Definition: mode.c:44
#define _T(x)
Definition: vfdio.h:22
char TCHAR
Definition: xmlstorage.h:189
#define _tcslen
Definition: xmlstorage.h:198
#define _tcsicmp
Definition: xmlstorage.h:205

◆ GetHelpShortDescriptionString()

const TCHAR * CShellCommandDeleteKey::GetHelpShortDescriptionString ( )
virtual

Implements CShellCommand.

Definition at line 172 of file ShellCommandDeleteKey.cpp.

173{
174 return DK_CMD_SHORT_DESC;
175}
#define DK_CMD_SHORT_DESC

◆ GetHelpString()

const TCHAR * CShellCommandDeleteKey::GetHelpString ( )
virtual

Implements CShellCommand.

Definition at line 162 of file ShellCommandDeleteKey.cpp.

163{
164 return DK_CMD_SHORT_DESC
165 _T("Syntax: ") DK_CMD _T(" [/s] [/?] [PATH]KEY_NAME\n\n")
166 _T(" PATH - optional path to key which subkey(s) will be deleted. Default is current key.")
167 _T(" KEY_NAME - name of key to be deleted. Wildcards can be used.")
168 _T(" /? - This help.\n\n")
169 _T(" /s - Delete key and all subkeys.\n");
170}
@ optional
Definition: SystemMenu.c:34
static int used
Definition: adh-main.c:39
@ KEY_NAME
Definition: import.c:63
int help
Definition: sort.c:20
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
GLdouble n
Definition: glext.h:7729
struct task_struct * current
Definition: linux.c:32
Definition: path.h:35
Definition: copy.c:22
Definition: name.c:39
static GLenum which
Definition: wgl_font.c:159

Referenced by Execute().

◆ Match()

BOOL CShellCommandDeleteKey::Match ( const TCHAR pchCommand)
virtual

Implements CShellCommand.

Definition at line 45 of file ShellCommandDeleteKey.cpp.

46{
47 return _tcsicmp(pchCommand,DK_CMD) == 0;
48}

Member Data Documentation

◆ m_rTree

CRegistryTree& CShellCommandDeleteKey::m_rTree
private

Definition at line 22 of file ShellCommandDeleteKey.h.

Referenced by Execute().


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