1 /* $Id: ShellCommandNewKey.cpp,v 1.1 2000/10/04 21:04:31 ea Exp $
3 * regexpl - Console Registry Explorer
5 * Copyright (c) 1999-2000 Nedko Arnaoudov <nedkohome@atia.com>
11 // ShellCommandNewKey.cpp: implementation of the CShellCommandNewKey class.
13 //////////////////////////////////////////////////////////////////////
16 #include "ShellCommandNewKey.h"
17 #include "RegistryExplorer.h"
19 #define NK_CMD _T("NK")
20 #define NK_CMD_SHORT_DESC NK_CMD _T(" command is used to create new key.\n")
22 //////////////////////////////////////////////////////////////////////
23 // Construction/Destruction
24 //////////////////////////////////////////////////////////////////////
26 CShellCommandNewKey::CShellCommandNewKey(CRegistryTree
& rTree
):m_rTree(rTree
)
30 CShellCommandNewKey::~CShellCommandNewKey()
34 BOOL
CShellCommandNewKey::Match(const TCHAR
*pchCommand
)
36 return _tcsicmp(pchCommand
,NK_CMD
) == 0;
39 int CShellCommandNewKey::Execute(CConsole
&rConsole
, CArgumentParser
& rArguments
)
41 const TCHAR
*pchNewKey
= NULL
, *pchArg
;
44 BOOL blnExitAfterHelp
= FALSE
;
45 BOOL blnVolatile
= FALSE
;
47 while((pchArg
= rArguments
.GetNextArgument()) != NULL
)
49 if ((_tcsicmp(pchArg
,_T("/?")) == 0)
50 ||(_tcsicmp(pchArg
,_T("-?")) == 0))
54 else if ((_tcsicmp(pchArg
,_T("/v")) == 0)
55 ||(_tcsicmp(pchArg
,_T("-v")) == 0))
63 rConsole
.Write(_T("Wrong parameter : \""));
64 rConsole
.Write(pchArg
);
65 rConsole
.Write(_T("\"\n\n"));
75 if ((!blnHelp
) && (!pchNewKey
))
77 rConsole
.Write(_T("Key name not specified !\n\n"));
78 blnExitAfterHelp
= TRUE
;
83 rConsole
.Write(GetHelpString());
87 rConsole
.Write(_T("\n"));
90 if (m_rTree
.IsCurrentRoot())
92 rConsole
.Write(NK_CMD COMMAND_NA_ON_ROOT
);
96 if (!m_rTree
.NewKey(pchNewKey
,blnVolatile
))
98 rConsole
.Write(_T("Cannot create key.\n"));
99 rConsole
.Write(m_rTree
.GetLastErrorDescription());
104 const TCHAR
* CShellCommandNewKey::GetHelpString()
106 return NK_CMD_SHORT_DESC
107 _T("Syntax: ") NK_CMD
_T(" [/v] [/?] Key_Name\n\n")
108 _T(" /? - This help.\n\n")
109 _T(" /v - Create volatile key. The information is stored in memory and is not\n")
110 _T(" preserved when the corresponding registry hive is unloaded.\n");
113 const TCHAR
* CShellCommandNewKey::GetHelpShortDescriptionString()
115 return NK_CMD_SHORT_DESC
;