Reactos
at master 105 lines 3.1 kB view raw
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// 24////////////////////////////////////////////////////////////////////// 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////////////////////////////////////////////////////////////////////// 34// Construction/Destruction 35////////////////////////////////////////////////////////////////////// 36 37CShellCommandChangeKey::CShellCommandChangeKey(CRegistryTree& rTree):m_rTree(rTree) 38{ 39 40} 41 42CShellCommandChangeKey::~CShellCommandChangeKey() 43{ 44 45} 46 47BOOL CShellCommandChangeKey::Match(const TCHAR *pchCommand) 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 58int CShellCommandChangeKey::Execute(CConsole &rConsole, CArgumentParser& rArguments) 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); 76 ASSERT(size <= PROMPT_BUFFER_SIZE); 77 78 if (!m_rTree.ChangeCurrentKey(pchPath)) 79 { 80 rConsole.Write(m_rTree.GetLastErrorDescription()); 81 rConsole.Write(_T("\n")); 82 } 83 } 84 else 85 { 86 rConsole.Write(GetHelpString()); 87 } 88 89 return 0; 90} 91 92const TCHAR * CShellCommandChangeKey::GetHelpString() 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 101const TCHAR * CShellCommandChangeKey::GetHelpShortDescriptionString() 102{ 103 return CD_CMD_SHORT_DESC; 104} 105