ReactOS  0.4.15-dev-313-g8fde48b
ShellCommandChangeKey.cpp
Go to the documentation of this file.
1 /*
2  * regexpl - Console Registry Explorer
3  *
4  * Copyright (C) 2000-2005 Nedko Arnaudov <nedko@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 // ShellCommandChangeKey.cpp: implementation of the CShellCommandChangeKey class.
23 //
25 
26 #include "ph.h"
27 #include "RegistryExplorer.h"
28 #include "ShellCommandChangeKey.h"
29 
30 #define CD_CMD _T("CD")
31 #define CD_CMD_LENGTH COMMAND_LENGTH(CD_CMD)
32 #define CD_CMD_SHORT_DESC CD_CMD _T(" command changes current key.\n")
33 // Construction/Destruction
36 
38 {
39 
40 }
41 
43 {
44 
45 }
46 
48 {
49  if (_tcsicmp(pchCommand,CD_CMD) == 0)
50  return TRUE;
51  if (_tcsnicmp(pchCommand,CD_CMD _T(".."),CD_CMD_LENGTH+1*sizeof(TCHAR)) == 0)
52  return TRUE;
53  if (_tcsnicmp(pchCommand,CD_CMD _T("\\"),CD_CMD_LENGTH+2*sizeof(TCHAR)) == 0)
54  return TRUE;
55  return FALSE;
56 }
57 
59 {
60  BOOL blnHelp = FALSE;
61 
62  rArguments.ResetArgumentIteration();
63  const TCHAR *pchCommandItself = rArguments.GetNextArgument();
64  const TCHAR *pchPath = rArguments.GetNextArgument();
65 
66  if ((_tcsnicmp(pchCommandItself,CD_CMD _T(".."),CD_CMD_LENGTH+2*sizeof(TCHAR)) == 0)||
67  (_tcsnicmp(pchCommandItself,CD_CMD _T("\\"),CD_CMD_LENGTH+1*sizeof(TCHAR)) == 0))
68  {
69  if (!pchPath) pchPath = pchCommandItself + CD_CMD_LENGTH;
70  else blnHelp = TRUE;
71  }
72 
73  if ((!blnHelp)&&(pchPath != NULL)&&(!rArguments.GetNextArgument()))
74  {
75  size_t size = _tcslen(pchPath);
77 
78  if (!m_rTree.ChangeCurrentKey(pchPath))
79  {
81  rConsole.Write(_T("\n"));
82  }
83  }
84  else
85  {
86  rConsole.Write(GetHelpString());
87  }
88 
89  return 0;
90 }
91 
93 {
94  return CD_CMD_SHORT_DESC
95  _T("Syntax: ") CD_CMD _T(" <KEY>\n\n")
96  _T(" <KEY> - Relative path of desired key.\n\n")
97  _T("Without parameters, command displays this help.\n");
98 
99 }
100 
102 {
103  return CD_CMD_SHORT_DESC;
104 }
105 
#define TRUE
Definition: types.h:120
#define _tcsicmp
Definition: xmlstorage.h:205
#define CD_CMD_LENGTH
virtual const TCHAR * GetHelpString()
virtual BOOL Match(const TCHAR *pchCommand)
#define PROMPT_BUFFER_SIZE
#define CD_CMD_SHORT_DESC
BOOL ChangeCurrentKey(const TCHAR *pchRelativePath)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _tcsnicmp
Definition: xmlstorage.h:207
TCHAR * GetNextArgument()
void ResetArgumentIteration()
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
GLsizeiptr size
Definition: glext.h:5919
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
const TCHAR * GetLastErrorDescription()
CShellCommandChangeKey(CRegistryTree &rTree)
virtual int Execute(CConsole &rConsole, CArgumentParser &rArguments)
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
virtual const TCHAR * GetHelpShortDescriptionString()
#define CD_CMD