ReactOS 0.4.15-dev-7942-gd23573b
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"
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")
34// 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{
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 PROMPT_BUFFER_SIZE
#define CD_CMD_LENGTH
#define CD_CMD_SHORT_DESC
#define CD_CMD
void ResetArgumentIteration()
TCHAR * GetNextArgument()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
Definition: Console.cpp:90
const TCHAR * GetLastErrorDescription()
BOOL ChangeCurrentKey(const TCHAR *pchRelativePath)
virtual const TCHAR * GetHelpString()
virtual BOOL Match(const TCHAR *pchCommand)
CShellCommandChangeKey(CRegistryTree &rTree)
virtual int Execute(CConsole &rConsole, CArgumentParser &rArguments)
virtual const TCHAR * GetHelpShortDescriptionString()
#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
GLsizeiptr size
Definition: glext.h:5919
#define ASSERT(a)
Definition: mode.c:44
#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