1 /* $Id: ShellCommandChangeKey.cpp,v 1.1 2000/10/04 21:04:30 ea Exp $
3 * regexpl - Console Registry Explorer
5 * Copyright (c) 1999-2000 Nedko Arnaoudov <nedkohome@atia.com>
11 // ShellCommandChangeKey.cpp: implementation of the CShellCommandChangeKey class.
13 //////////////////////////////////////////////////////////////////////
16 #include "RegistryExplorer.h"
17 #include "ShellCommandChangeKey.h"
19 #define CD_CMD _T("CD")
20 #define CD_CMD_LENGTH COMMAND_LENGTH(CD_CMD)
21 #define CD_CMD_SHORT_DESC CD_CMD _T(" command changes current key.\n")
22 //////////////////////////////////////////////////////////////////////
23 // Construction/Destruction
24 //////////////////////////////////////////////////////////////////////
26 CShellCommandChangeKey::CShellCommandChangeKey(CRegistryTree
& rTree
):m_rTree(rTree
)
31 CShellCommandChangeKey::~CShellCommandChangeKey()
36 BOOL
CShellCommandChangeKey::Match(const TCHAR
*pchCommand
)
38 if (_tcsicmp(pchCommand
,CD_CMD
) == 0)
40 if (_tcsnicmp(pchCommand
,CD_CMD
_T(".."),CD_CMD_LENGTH
+1*sizeof(TCHAR
)) == 0)
42 if (_tcsnicmp(pchCommand
,CD_CMD
_T("\\"),CD_CMD_LENGTH
+2*sizeof(TCHAR
)) == 0)
47 int CShellCommandChangeKey::Execute(CConsole
&rConsole
, CArgumentParser
& rArguments
)
51 rArguments
.ResetArgumentIteration();
52 const TCHAR
*pchCommandItself
= rArguments
.GetNextArgument();
53 const TCHAR
*pchPath
= rArguments
.GetNextArgument();
55 if ((_tcsnicmp(pchCommandItself
,CD_CMD
_T(".."),CD_CMD_LENGTH
+2*sizeof(TCHAR
)) == 0)||
56 (_tcsnicmp(pchCommandItself
,CD_CMD
_T("\\"),CD_CMD_LENGTH
+1*sizeof(TCHAR
)) == 0))
58 if (!pchPath
) pchPath
= pchCommandItself
+ CD_CMD_LENGTH
;
62 if ((!blnHelp
)&&(pchPath
!= NULL
)&&(!rArguments
.GetNextArgument()))
64 ASSERT(_tcslen(pchPath
) <= PROMPT_BUFFER_SIZE
);
65 if (!m_rTree
.ChangeCurrentKey(pchPath
))
67 rConsole
.Write(m_rTree
.GetLastErrorDescription());
68 rConsole
.Write(_T("\n"));
73 rConsole
.Write(GetHelpString());
79 const TCHAR
* CShellCommandChangeKey::GetHelpString()
81 return CD_CMD_SHORT_DESC
82 _T("Syntax: ") CD_CMD
_T(" <KEY>\n\n")
83 _T(" <KEY> - Relative path of desired key.\n\n")
84 _T("Without parameters, command displays this help.\n");
88 const TCHAR
* CShellCommandChangeKey::GetHelpShortDescriptionString()
90 return CD_CMD_SHORT_DESC
;