ReactOS 0.4.15-dev-7942-gd23573b
CShellCommandDeleteValue Class Reference

#include <ShellCommandDeleteValue.h>

Inheritance diagram for CShellCommandDeleteValue:
Collaboration diagram for CShellCommandDeleteValue:

Public Member Functions

 CShellCommandDeleteValue (CRegistryTree &rTree)
 
virtual ~CShellCommandDeleteValue ()
 
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 ShellCommandDeleteValue.h.

Constructor & Destructor Documentation

◆ CShellCommandDeleteValue()

CShellCommandDeleteValue::CShellCommandDeleteValue ( CRegistryTree rTree)

Definition at line 39 of file ShellCommandDeleteValue.cpp.

39 :m_rTree(rTree)
40{
41}

◆ ~CShellCommandDeleteValue()

CShellCommandDeleteValue::~CShellCommandDeleteValue ( )
virtual

Definition at line 43 of file ShellCommandDeleteValue.cpp.

44{
45}

Member Function Documentation

◆ Execute()

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

Implements CShellCommand.

Definition at line 52 of file ShellCommandDeleteValue.cpp.

53{
54 rArguments.ResetArgumentIteration();
55 TCHAR *pszCommandItself = rArguments.GetNextArgument();
56
57 TCHAR *pszParameter;
58 TCHAR *pszValueFull = NULL;
59 BOOL blnHelp = FALSE;
60
61 if ((_tcsnicmp(pszCommandItself,DV_CMD _T(".."),DV_CMD_LENGTH+2*sizeof(TCHAR)) == 0)||
62 (_tcsnicmp(pszCommandItself,DV_CMD _T("\\"),DV_CMD_LENGTH+1*sizeof(TCHAR)) == 0))
63 {
64 pszValueFull = pszCommandItself + DV_CMD_LENGTH;
65 }
66 else if (_tcsnicmp(pszCommandItself,DV_CMD _T("/"),DV_CMD_LENGTH+1*sizeof(TCHAR)) == 0)
67 {
68 pszParameter = pszCommandItself + DV_CMD_LENGTH;
69 goto CheckValueArgument;
70 }
71
72 while((pszParameter = rArguments.GetNextArgument()) != NULL)
73 {
74CheckValueArgument:
75 if ((_tcsicmp(pszParameter,_T("/?")) == 0)
76 ||(_tcsicmp(pszParameter,_T("-?")) == 0))
77 {
78 blnHelp = TRUE;
79 break;
80 }
81 else if (!pszValueFull)
82 {
83 pszValueFull = pszParameter;
84 }
85 else
86 {
87 rConsole.Write(_T("Bad parameter: "));
88 rConsole.Write(pszParameter);
89 rConsole.Write(_T("\n"));
90 }
91 }
92
94 TCHAR *pszValueNamePattern;
95 const TCHAR *pszEmpty = _T("");
96 const TCHAR *pszPath;
97
98 if (blnHelp)
99 {
100 rConsole.Write(GetHelpString());
101 return 0;
102 }
103
104 if (pszValueFull)
105 {
106 if (_tcscmp(pszValueFull,_T("\\")) == 0)
107 goto CommandNAonRoot;
108
109 TCHAR *pchSep = _tcsrchr(pszValueFull,_T('\\'));
110 pszValueNamePattern = pchSep?(pchSep+1):(pszValueFull);
111 pszPath = pchSep?pszValueFull:_T(".");
112
113 if (pchSep)
114 *pchSep = 0;
115 }
116 else
117 {
118 pszValueNamePattern = (TCHAR*)pszEmpty;
119 pszPath = _T(".");
120 }
121
122 {
123 size_t s = _tcslen(pszValueNamePattern);
124 if (s && (pszValueNamePattern[0] == _T('\"'))&&(pszValueNamePattern[s-1] == _T('\"')))
125 {
126 pszValueNamePattern[s-1] = 0;
127 pszValueNamePattern++;
128 }
129 }
130
132 {
134 return 0;
135 }
136
137 if (!Key.IsRoot())
138 { // not root key ???
139 TCHAR Buffer[254];
140 DWORD dwMaxValueNameLength;
141 LONG nError = Key.GetMaxValueNameLength(dwMaxValueNameLength);
142 if (nError != ERROR_SUCCESS)
143 {
144 _stprintf(Buffer,_T("Cannot query info about %s key. Error is %u\n"),Key.GetKeyName(),(unsigned int)nError);
145 rConsole.Write(Buffer);
146 return 0;
147 }
148
149 TCHAR *pszValueName = new (std::nothrow) TCHAR[dwMaxValueNameLength];
150 if (!pszValueName)
151 {
152 rConsole.Write("Out of memory.");
153 return 0;
154 }
155
156 Key.InitValueEnumeration(pszValueName,dwMaxValueNameLength,NULL,0,NULL);
157
158 while ((nError = Key.GetNextValue()) == ERROR_SUCCESS)
159 {
160 if (PatternMatch(pszValueNamePattern,pszValueName))
161 {
162 nError = Key.DeleteValue(pszValueName);
163 if (nError != ERROR_SUCCESS)
164 {
165 _stprintf(Buffer,_T("Cannot delete value. Error is %u\n"),(unsigned int)nError);
166 rConsole.Write(Buffer);
167 }
168 else
169 {
171 }
172 Key.InitValueEnumeration(pszValueName,dwMaxValueNameLength,NULL,0,NULL); // reset iteration
173 }
174 }
175 } // if (pKey)
176 else
177 {
178CommandNAonRoot:
180 }
181
182 return 0;
183}
void InvalidateCompletion()
Definition: Completion.cpp:511
BOOL PatternMatch(const TCHAR *pszPattern, const TCHAR *pszTry)
Definition: Pattern.cpp:28
#define COMMAND_NA_ON_ROOT
#define DV_CMD_LENGTH
#define DV_CMD
Definition: bufpool.h:45
void ResetArgumentIteration()
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
BOOL GetKey(const TCHAR *pchRelativePath, REGSAM DesiredAccess, CRegistryKey &rKey)
const TCHAR * GetLastErrorDescription()
virtual const TCHAR * GetHelpString()
#define ERROR_SUCCESS
Definition: deptool.c:10
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble s
Definition: gl.h:2039
#define _tcscmp
Definition: tchar.h:1424
#define _stprintf
Definition: utility.h:124
#define _tcsrchr
Definition: utility.h:116
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_SET_VALUE
Definition: nt_native.h:1017
long LONG
Definition: pedump.c:60
#define _T(x)
Definition: vfdio.h:22
char TCHAR
Definition: xmlstorage.h:189
#define _tcsnicmp
Definition: xmlstorage.h:207
#define _tcslen
Definition: xmlstorage.h:198
#define _tcsicmp
Definition: xmlstorage.h:205

◆ GetHelpShortDescriptionString()

const TCHAR * CShellCommandDeleteValue::GetHelpShortDescriptionString ( )
virtual

Implements CShellCommand.

Definition at line 194 of file ShellCommandDeleteValue.cpp.

195{
196 return DV_CMD_SHORT_DESC;
197}
#define DV_CMD_SHORT_DESC

◆ GetHelpString()

const TCHAR * CShellCommandDeleteValue::GetHelpString ( )
virtual

Implements CShellCommand.

Definition at line 185 of file ShellCommandDeleteValue.cpp.

186{
187 return DV_CMD_SHORT_DESC
188 _T("Syntax: ") DV_CMD _T(" [<PATH>][<VALUE_NAME>] [/?]\n\n")
189 _T(" <PATH> - Optional relative path of key which value will be delete.\n")
190 _T(" <VALUE_NAME> - Name pattern of key's value. Default is key's default value.\n")
191 _T(" /? - This help.\n\n");
192}
int help
Definition: sort.c:20
GLdouble n
Definition: glext.h:7729
GLubyte * pattern
Definition: glext.h:7787
@ VALUE_NAME
Definition: inffile.c:76
Definition: path.h:35
Definition: copy.c:22
#define delete(ptr)
Definition: treelist.c:56
Definition: pdh_main.c:94
static GLenum which
Definition: wgl_font.c:159

Referenced by Execute().

◆ Match()

BOOL CShellCommandDeleteValue::Match ( const TCHAR pchCommand)
virtual

Implements CShellCommand.

Definition at line 47 of file ShellCommandDeleteValue.cpp.

48{
49 return _tcsicmp(pszCommand,DV_CMD) == 0;
50}

Member Data Documentation

◆ m_rTree

CRegistryTree& CShellCommandDeleteValue::m_rTree
private

Definition at line 22 of file ShellCommandDeleteValue.h.

Referenced by Execute().


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