ReactOS  0.4.14-dev-55-g2da92ac
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 ()
 

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  {
130  rConsole.Write(DK_CMD COMMAND_NA_ON_ROOT);
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 }
#define TRUE
Definition: types.h:120
#define _tcsicmp
Definition: xmlstorage.h:205
#define pch(ap)
Definition: match.c:418
#define DK_CMD
unsigned int BOOL
Definition: ntddk_ex.h:94
TCHAR * GetNextArgument()
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
const TCHAR * GetLastErrorDescription()
GLdouble s
Definition: gl.h:2039
#define COMMAND_NA_ON_ROOT
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
virtual const TCHAR * GetHelpString()
BOOL DeleteSubkeys(const TCHAR *pszKeyPattern, const TCHAR *pszPath, BOOL blnRecursive=FALSE)
void InvalidateCompletion()
Definition: Completion.cpp:511

◆ 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 }
static GLenum which
Definition: wgl_font.c:159
Definition: path.h:34
GLdouble n
Definition: glext.h:7729
#define DK_CMD
Definition: msg.h:41
c used
Definition: write.c:2877
#define _T(x)
Definition: vfdio.h:22
#define DK_CMD_SHORT_DESC
GLdouble s
Definition: gl.h:2039
Definition: services.c:325
Definition: name.c:36
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
int help
Definition: sort.c:20
struct task_struct * current
Definition: linux.c:32
Definition: path.c:42

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 }
#define _tcsicmp
Definition: xmlstorage.h:205
#define DK_CMD

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: