ReactOS  0.4.14-dev-115-g4576127
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 ()
 

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  {
130  rConsole.Write(NK_CMD COMMAND_NA_ON_ROOT);
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 }
#define TRUE
Definition: types.h:120
virtual const TCHAR * GetHelpString()
#define _tcsicmp
Definition: xmlstorage.h:205
#define pch(ap)
Definition: match.c:418
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
CRegistryTree & m_rTree
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
BOOL NewKey(const TCHAR *pszKeyName, const TCHAR *pszPath, BOOL blnVolatile=FALSE)
void InvalidateCompletion()
Definition: Completion.cpp:511
#define NK_CMD

◆ 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 }
_In_ BOOLEAN Create
Definition: pstypes.h:511
static GLenum which
Definition: wgl_font.c:159
Definition: path.h:34
GLdouble n
Definition: glext.h:7729
static char memory[1024 *256]
Definition: process.c:116
const char ** registry
Definition: cffdrivr.c:690
Definition: msg.h:41
#define volatile
Definition: prototyp.h:117
#define _T(x)
Definition: vfdio.h:22
#define NK_CMD_SHORT_DESC
const GLdouble * v
Definition: gl.h:2040
GLuint in
Definition: glext.h:9616
Definition: services.c:325
Definition: name.c:36
static PDB_INFORMATION information
Definition: db.cpp:176
int help
Definition: sort.c:20
#define NK_CMD
struct task_struct * current
Definition: linux.c:32
Definition: path.c:42

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

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: