ReactOS 0.4.15-dev-7924-g5949c20
CShellCommandNewKey Class Reference

#include <ShellCommandNewKey.h>

Inheritance diagram for CShellCommandNewKey:
Collaboration diagram for CShellCommandNewKey:

Public Member Functions

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

Constructor & Destructor Documentation

◆ CShellCommandNewKey()

CShellCommandNewKey::CShellCommandNewKey ( CRegistryTree rTree)

Definition at line 37 of file ShellCommandNewKey.cpp.

37 :m_rTree(rTree)
38{
39}
CRegistryTree & m_rTree

◆ ~CShellCommandNewKey()

CShellCommandNewKey::~CShellCommandNewKey ( )
virtual

Definition at line 41 of file ShellCommandNewKey.cpp.

42{
43}

Member Function Documentation

◆ Execute()

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

Implements CShellCommand.

Definition at line 50 of file ShellCommandNewKey.cpp.

51{
52 TCHAR *pszNewKey = NULL, *pszArg;
53
54 BOOL blnHelp = FALSE;
55 BOOL blnExitAfterHelp = FALSE;
56 BOOL blnVolatile = FALSE;
57
58 while((pszArg = rArguments.GetNextArgument()) != NULL)
59 {
60 if ((_tcsicmp(pszArg,_T("/?")) == 0)
61 ||(_tcsicmp(pszArg,_T("-?")) == 0))
62 {
63 blnHelp = TRUE;
64 }
65 else if ((_tcsicmp(pszArg,_T("/v")) == 0)
66 ||(_tcsicmp(pszArg,_T("-v")) == 0))
67 {
68 blnVolatile = TRUE;
69 }
70 else
71 {
72 if (pszNewKey)
73 {
74 rConsole.Write(_T("Wrong parameter : \""));
75 rConsole.Write(pszArg);
76 rConsole.Write(_T("\"\n\n"));
77 blnHelp = TRUE;
78 }
79 else
80 {
81 pszNewKey = pszArg;
82 }
83 }
84 }
85
86 if (!pszNewKey)
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 = pszNewKey;
103 while(*pch) // search end of string
104 pch++;
105
106 if (pch > pszNewKey) // last non-null char
107 pch--;
108
109 while(*pch == _T('\\')) // ignore ending backslashes
110 *pch = 0;
111
112 while((pch > pszNewKey)&&(*pch != _T('\\')))
113 pch--;
114
115 ASSERT(pch >= pszNewKey);
116
117 const TCHAR *pszPath;
118 TCHAR *pszSubkeyName = pch;
119 if (*pch == _T('\\'))
120 pszSubkeyName++;
121
122 if (pch == pszNewKey)
123 {
124 pszPath = _T(".");
125 }
126 else
127 {
128 if (pch-1 == pszNewKey)
129 {
131 return 0;
132 }
133 else
134 {
135 *pch = 0;
136 pszPath = pszNewKey;
137 }
138 }
139
140 {
141 size_t s = _tcslen(pszSubkeyName);
142 if (s && (pszSubkeyName[0] == _T('\"')) && (pszSubkeyName[s-1] == _T('\"')))
143 {
144 pszSubkeyName[s-1] = 0;
145 pszSubkeyName++;
146 }
147 }
148
149 if (!m_rTree.NewKey(pszSubkeyName,pszPath,blnVolatile))
150 {
151 rConsole.Write(_T("Cannot create key.\n"));
153 }
154 else
155 {
157 }
158
159 return 0;
160}
void InvalidateCompletion()
Definition: Completion.cpp:511
#define COMMAND_NA_ON_ROOT
#define NK_CMD
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
BOOL NewKey(const TCHAR *pszKeyName, const TCHAR *pszPath, BOOL blnVolatile=FALSE)
const TCHAR * GetLastErrorDescription()
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 * CShellCommandNewKey::GetHelpShortDescriptionString ( )
virtual

Implements CShellCommand.

Definition at line 173 of file ShellCommandNewKey.cpp.

174{
175 return NK_CMD_SHORT_DESC;
176}
#define NK_CMD_SHORT_DESC

◆ GetHelpString()

const TCHAR * CShellCommandNewKey::GetHelpString ( )
virtual

Implements CShellCommand.

Definition at line 162 of file ShellCommandNewKey.cpp.

163{
164 return NK_CMD_SHORT_DESC
165 _T("Syntax: ") NK_CMD _T(" [/v] [/?] [PATH]KEY_NAME\n\n")
166 _T(" PATH - optional path to key which subkey will be created. Default is current key.\n")
167 _T(" KEY_NAME - name of subkey to be created.\n")
168 _T(" /? - This help.\n")
169 _T(" /v - Create volatile key. The information is stored in memory and is not\n")
170 _T(" preserved when the corresponding registry hive is unloaded.\n");
171}
@ optional
Definition: SystemMenu.c:34
@ KEY_NAME
Definition: import.c:63
int help
Definition: sort.c:20
@ Create
Definition: registry.c:563
const char ** registry
Definition: cffdrivr.c:690
static PDB_INFORMATION information
Definition: db.cpp:178
const GLdouble * v
Definition: gl.h:2040
GLdouble n
Definition: glext.h:7729
GLuint in
Definition: glext.h:9616
struct task_struct * current
Definition: linux.c:32
static char memory[1024 *256]
Definition: process.c:116
#define volatile
Definition: prototyp.h:117
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 CShellCommandNewKey::Match ( const TCHAR pchCommand)
virtual

Implements CShellCommand.

Definition at line 45 of file ShellCommandNewKey.cpp.

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

Member Data Documentation

◆ m_rTree

CRegistryTree& CShellCommandNewKey::m_rTree
private

Definition at line 22 of file ShellCommandNewKey.h.

Referenced by Execute().


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