1 /* $Id: ShellCommandChangeKey.cpp,v 1.2 2000/10/24 20:17:41 narnaoud Exp $
3 * regexpl - Console Registry Explorer
5 * Copyright (C) 2000 Nedko Arnaoudov <nedkohome@atia.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 // ShellCommandChangeKey.cpp: implementation of the CShellCommandChangeKey class.
25 //////////////////////////////////////////////////////////////////////
28 #include "RegistryExplorer.h"
29 #include "ShellCommandChangeKey.h"
31 #define CD_CMD _T("CD")
32 #define CD_CMD_LENGTH COMMAND_LENGTH(CD_CMD)
33 #define CD_CMD_SHORT_DESC CD_CMD _T(" command changes current key.\n")
34 //////////////////////////////////////////////////////////////////////
35 // Construction/Destruction
36 //////////////////////////////////////////////////////////////////////
38 CShellCommandChangeKey::CShellCommandChangeKey(CRegistryTree
& rTree
):m_rTree(rTree
)
43 CShellCommandChangeKey::~CShellCommandChangeKey()
48 BOOL
CShellCommandChangeKey::Match(const TCHAR
*pchCommand
)
50 if (_tcsicmp(pchCommand
,CD_CMD
) == 0)
52 if (_tcsnicmp(pchCommand
,CD_CMD
_T(".."),CD_CMD_LENGTH
+1*sizeof(TCHAR
)) == 0)
54 if (_tcsnicmp(pchCommand
,CD_CMD
_T("\\"),CD_CMD_LENGTH
+2*sizeof(TCHAR
)) == 0)
59 int CShellCommandChangeKey::Execute(CConsole
&rConsole
, CArgumentParser
& rArguments
)
63 rArguments
.ResetArgumentIteration();
64 const TCHAR
*pchCommandItself
= rArguments
.GetNextArgument();
65 const TCHAR
*pchPath
= rArguments
.GetNextArgument();
67 if ((_tcsnicmp(pchCommandItself
,CD_CMD
_T(".."),CD_CMD_LENGTH
+2*sizeof(TCHAR
)) == 0)||
68 (_tcsnicmp(pchCommandItself
,CD_CMD
_T("\\"),CD_CMD_LENGTH
+1*sizeof(TCHAR
)) == 0))
70 if (!pchPath
) pchPath
= pchCommandItself
+ CD_CMD_LENGTH
;
74 if ((!blnHelp
)&&(pchPath
!= NULL
)&&(!rArguments
.GetNextArgument()))
76 ASSERT(_tcslen(pchPath
) <= PROMPT_BUFFER_SIZE
);
77 if (!m_rTree
.ChangeCurrentKey(pchPath
))
79 rConsole
.Write(m_rTree
.GetLastErrorDescription());
80 rConsole
.Write(_T("\n"));
85 rConsole
.Write(GetHelpString());
91 const TCHAR
* CShellCommandChangeKey::GetHelpString()
93 return CD_CMD_SHORT_DESC
94 _T("Syntax: ") CD_CMD
_T(" <KEY>\n\n")
95 _T(" <KEY> - Relative path of desired key.\n\n")
96 _T("Without parameters, command displays this help.\n");
100 const TCHAR
* CShellCommandChangeKey::GetHelpShortDescriptionString()
102 return CD_CMD_SHORT_DESC
;