1 /* $Id: ShellCommandNewKey.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 // ShellCommandNewKey.cpp: implementation of the CShellCommandNewKey class.
25 //////////////////////////////////////////////////////////////////////
28 #include "ShellCommandNewKey.h"
29 #include "RegistryExplorer.h"
31 #define NK_CMD _T("NK")
32 #define NK_CMD_SHORT_DESC NK_CMD _T(" command is used to create new key.\n")
34 //////////////////////////////////////////////////////////////////////
35 // Construction/Destruction
36 //////////////////////////////////////////////////////////////////////
38 CShellCommandNewKey::CShellCommandNewKey(CRegistryTree
& rTree
):m_rTree(rTree
)
42 CShellCommandNewKey::~CShellCommandNewKey()
46 BOOL
CShellCommandNewKey::Match(const TCHAR
*pchCommand
)
48 return _tcsicmp(pchCommand
,NK_CMD
) == 0;
51 int CShellCommandNewKey::Execute(CConsole
&rConsole
, CArgumentParser
& rArguments
)
53 const TCHAR
*pchNewKey
= NULL
, *pchArg
;
56 BOOL blnExitAfterHelp
= FALSE
;
57 BOOL blnVolatile
= FALSE
;
59 while((pchArg
= rArguments
.GetNextArgument()) != NULL
)
61 if ((_tcsicmp(pchArg
,_T("/?")) == 0)
62 ||(_tcsicmp(pchArg
,_T("-?")) == 0))
66 else if ((_tcsicmp(pchArg
,_T("/v")) == 0)
67 ||(_tcsicmp(pchArg
,_T("-v")) == 0))
75 rConsole
.Write(_T("Wrong parameter : \""));
76 rConsole
.Write(pchArg
);
77 rConsole
.Write(_T("\"\n\n"));
87 if ((!blnHelp
) && (!pchNewKey
))
89 rConsole
.Write(_T("Key name not specified !\n\n"));
90 blnExitAfterHelp
= TRUE
;
95 rConsole
.Write(GetHelpString());
99 rConsole
.Write(_T("\n"));
102 if (m_rTree
.IsCurrentRoot())
104 rConsole
.Write(NK_CMD COMMAND_NA_ON_ROOT
);
108 if (!m_rTree
.NewKey(pchNewKey
,blnVolatile
))
110 rConsole
.Write(_T("Cannot create key.\n"));
111 rConsole
.Write(m_rTree
.GetLastErrorDescription());
116 const TCHAR
* CShellCommandNewKey::GetHelpString()
118 return NK_CMD_SHORT_DESC
119 _T("Syntax: ") NK_CMD
_T(" [/v] [/?] Key_Name\n\n")
120 _T(" /? - This help.\n\n")
121 _T(" /v - Create volatile key. The information is stored in memory and is not\n")
122 _T(" preserved when the corresponding registry hive is unloaded.\n");
125 const TCHAR
* CShellCommandNewKey::GetHelpShortDescriptionString()
127 return NK_CMD_SHORT_DESC
;