mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:33:01 +00:00
no message
svn path=/trunk/; revision=1507
This commit is contained in:
parent
15491f14dd
commit
bf1b057da3
51 changed files with 320 additions and 197 deletions
|
@ -1,8 +1,8 @@
|
|||
/* $Id: ShellCommandDeleteValue.cpp,v 1.3 2001/01/10 01:25:29 narnaoud Exp $
|
||||
/* $Id: ShellCommandDeleteValue.cpp,v 1.4 2001/01/13 23:55:37 narnaoud Exp $
|
||||
*
|
||||
* regexpl - Console Registry Explorer
|
||||
*
|
||||
* Copyright (C) 2000 Nedko Arnaoudov <nedkohome@atia.com>
|
||||
* Copyright (C) 2000,2001 Nedko Arnaoudov <nedkohome@atia.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,6 +27,7 @@
|
|||
#include "ph.h"
|
||||
#include "ShellCommandDeleteValue.h"
|
||||
#include "RegistryExplorer.h"
|
||||
#include "Pattern.h"
|
||||
|
||||
#define DV_CMD _T("DV")
|
||||
#define DV_CMD_LENGTH COMMAND_LENGTH(DV_CMD)
|
||||
|
@ -51,119 +52,134 @@ BOOL CShellCommandDeleteValue::Match(const TCHAR *pszCommand)
|
|||
|
||||
int CShellCommandDeleteValue::Execute(CConsole &rConsole, CArgumentParser& rArguments)
|
||||
{
|
||||
rArguments.ResetArgumentIteration();
|
||||
TCHAR *pszCommandItself = rArguments.GetNextArgument();
|
||||
rArguments.ResetArgumentIteration();
|
||||
TCHAR *pszCommandItself = rArguments.GetNextArgument();
|
||||
|
||||
TCHAR *pszParameter;
|
||||
TCHAR *pszValueFull = NULL;
|
||||
BOOL blnHelp = FALSE;
|
||||
// DWORD dwError;
|
||||
TCHAR *pszParameter;
|
||||
TCHAR *pszValueFull = NULL;
|
||||
BOOL blnHelp = FALSE;
|
||||
|
||||
if ((_tcsnicmp(pszCommandItself,DV_CMD _T(".."),DV_CMD_LENGTH+2*sizeof(TCHAR)) == 0)||
|
||||
(_tcsnicmp(pszCommandItself,DV_CMD _T("\\"),DV_CMD_LENGTH+1*sizeof(TCHAR)) == 0))
|
||||
{
|
||||
pszValueFull = pszCommandItself + DV_CMD_LENGTH;
|
||||
}
|
||||
else if (_tcsnicmp(pszCommandItself,DV_CMD _T("/"),DV_CMD_LENGTH+1*sizeof(TCHAR)) == 0)
|
||||
{
|
||||
pszParameter = pszCommandItself + DV_CMD_LENGTH;
|
||||
goto CheckValueArgument;
|
||||
}
|
||||
if ((_tcsnicmp(pszCommandItself,DV_CMD _T(".."),DV_CMD_LENGTH+2*sizeof(TCHAR)) == 0)||
|
||||
(_tcsnicmp(pszCommandItself,DV_CMD _T("\\"),DV_CMD_LENGTH+1*sizeof(TCHAR)) == 0))
|
||||
{
|
||||
pszValueFull = pszCommandItself + DV_CMD_LENGTH;
|
||||
}
|
||||
else if (_tcsnicmp(pszCommandItself,DV_CMD _T("/"),DV_CMD_LENGTH+1*sizeof(TCHAR)) == 0)
|
||||
{
|
||||
pszParameter = pszCommandItself + DV_CMD_LENGTH;
|
||||
goto CheckValueArgument;
|
||||
}
|
||||
|
||||
while((pszParameter = rArguments.GetNextArgument()) != NULL)
|
||||
{
|
||||
while((pszParameter = rArguments.GetNextArgument()) != NULL)
|
||||
{
|
||||
CheckValueArgument:
|
||||
if ((_tcsicmp(pszParameter,_T("/?")) == 0)
|
||||
||(_tcsicmp(pszParameter,_T("-?")) == 0))
|
||||
{
|
||||
blnHelp = TRUE;
|
||||
break;
|
||||
}
|
||||
else if (!pszValueFull)
|
||||
{
|
||||
pszValueFull = pszParameter;
|
||||
}
|
||||
else
|
||||
{
|
||||
rConsole.Write(_T("Bad parameter: "));
|
||||
rConsole.Write(pszParameter);
|
||||
rConsole.Write(_T("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
CRegistryKey Key;
|
||||
TCHAR *pszValueName;
|
||||
const TCHAR *pszPath;
|
||||
|
||||
if (blnHelp)
|
||||
{
|
||||
rConsole.Write(GetHelpString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pszValueFull)
|
||||
{
|
||||
if (_tcscmp(pszValueFull,_T("\\")) == 0)
|
||||
goto CommandNAonRoot;
|
||||
|
||||
TCHAR *pchSep = _tcsrchr(pszValueFull,_T('\\'));
|
||||
pszValueName = pchSep?(pchSep+1):(pszValueFull);
|
||||
pszPath = pchSep?pszValueFull:_T(".");
|
||||
|
||||
//if (_tcsrchr(pszValueName,_T('.')))
|
||||
//{
|
||||
// pszValueName = _T("");
|
||||
// pszPath = pszValueFull;
|
||||
//}
|
||||
//else
|
||||
if (pchSep)
|
||||
*pchSep = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszValueName = _T("");
|
||||
pszPath = _T(".");
|
||||
}
|
||||
|
||||
{
|
||||
size_t s = _tcslen(pszValueName);
|
||||
if (s && (pszValueName[0] == _T('\"'))&&(pszValueName[s-1] == _T('\"')))
|
||||
if ((_tcsicmp(pszParameter,_T("/?")) == 0)
|
||||
||(_tcsicmp(pszParameter,_T("-?")) == 0))
|
||||
{
|
||||
pszValueName[s-1] = 0;
|
||||
pszValueName++;
|
||||
blnHelp = TRUE;
|
||||
break;
|
||||
}
|
||||
else if (!pszValueFull)
|
||||
{
|
||||
pszValueFull = pszParameter;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_rTree.GetKey(pszPath,KEY_SET_VALUE,Key))
|
||||
{
|
||||
rConsole.Write(m_rTree.GetLastErrorDescription());
|
||||
goto SkipCommand;
|
||||
}
|
||||
|
||||
if (!Key.IsRoot())
|
||||
{ // not root key ???
|
||||
LONG nError = Key.DeleteValue(pszValueName);
|
||||
if (nError != ERROR_SUCCESS)
|
||||
{
|
||||
char Buffer[254];
|
||||
_stprintf(Buffer,_T("Cannot delete value. Error is %u\n"),(unsigned int)nError);
|
||||
rConsole.Write(Buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvalidateCompletion();
|
||||
rConsole.Write(_T("Bad parameter: "));
|
||||
rConsole.Write(pszParameter);
|
||||
rConsole.Write(_T("\n"));
|
||||
}
|
||||
} // if (pKey)
|
||||
else
|
||||
{
|
||||
CommandNAonRoot:
|
||||
rConsole.Write(DV_CMD COMMAND_NA_ON_ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
CRegistryKey Key;
|
||||
TCHAR *pszValueNamePattern;
|
||||
const TCHAR *pszPath;
|
||||
|
||||
if (blnHelp)
|
||||
{
|
||||
rConsole.Write(GetHelpString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
SkipCommand:
|
||||
// if (pTree)
|
||||
// delete pTree;
|
||||
return 0;
|
||||
if (pszValueFull)
|
||||
{
|
||||
if (_tcscmp(pszValueFull,_T("\\")) == 0)
|
||||
goto CommandNAonRoot;
|
||||
|
||||
TCHAR *pchSep = _tcsrchr(pszValueFull,_T('\\'));
|
||||
pszValueNamePattern = pchSep?(pchSep+1):(pszValueFull);
|
||||
pszPath = pchSep?pszValueFull:_T(".");
|
||||
|
||||
if (pchSep)
|
||||
*pchSep = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszValueNamePattern = _T("");
|
||||
pszPath = _T(".");
|
||||
}
|
||||
|
||||
{
|
||||
size_t s = _tcslen(pszValueNamePattern);
|
||||
if (s && (pszValueNamePattern[0] == _T('\"'))&&(pszValueNamePattern[s-1] == _T('\"')))
|
||||
{
|
||||
pszValueNamePattern[s-1] = 0;
|
||||
pszValueNamePattern++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_rTree.GetKey(pszPath,KEY_QUERY_VALUE|KEY_SET_VALUE,Key))
|
||||
{
|
||||
rConsole.Write(m_rTree.GetLastErrorDescription());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!Key.IsRoot())
|
||||
{ // not root key ???
|
||||
TCHAR Buffer[254];
|
||||
DWORD dwMaxValueNameLength;
|
||||
LONG nError = Key.GetMaxValueNameLength(dwMaxValueNameLength);
|
||||
if (nError != ERROR_SUCCESS)
|
||||
{
|
||||
_stprintf(Buffer,_T("Cannot query info about %s key. Error is %u\n"),Key.GetKeyName(),(unsigned int)nError);
|
||||
rConsole.Write(Buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
TCHAR *pszValueName = new TCHAR[dwMaxValueNameLength];
|
||||
if (!pszValueName)
|
||||
{
|
||||
rConsole.Write("Out of memory.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Key.InitValueEnumeration(pszValueName,dwMaxValueNameLength,NULL,0,NULL);
|
||||
|
||||
while ((nError = Key.GetNextValue()) == ERROR_SUCCESS)
|
||||
{
|
||||
if (PatternMatch(pszValueNamePattern,pszValueName))
|
||||
{
|
||||
nError = Key.DeleteValue(pszValueName);
|
||||
if (nError != ERROR_SUCCESS)
|
||||
{
|
||||
_stprintf(Buffer,_T("Cannot delete value. Error is %u\n"),(unsigned int)nError);
|
||||
rConsole.Write(Buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvalidateCompletion();
|
||||
}
|
||||
Key.InitValueEnumeration(pszValueName,dwMaxValueNameLength,NULL,0,NULL); // reset iteration
|
||||
}
|
||||
}
|
||||
} // if (pKey)
|
||||
else
|
||||
{
|
||||
CommandNAonRoot:
|
||||
rConsole.Write(DV_CMD COMMAND_NA_ON_ROOT);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const TCHAR * CShellCommandDeleteValue::GetHelpString()
|
||||
|
@ -171,7 +187,7 @@ const TCHAR * CShellCommandDeleteValue::GetHelpString()
|
|||
return DV_CMD_SHORT_DESC
|
||||
_T("Syntax: ") DV_CMD _T(" [<PATH>][<VALUE_NAME>] [/?]\n\n")
|
||||
_T(" <PATH> - Optional relative path of key which value will be delete.\n")
|
||||
_T(" <VALUE_NAME> - Name of key's value. Default is key's default value.\n")
|
||||
_T(" <VALUE_NAME> - Name pattern of key's value. Default is key's default value.\n")
|
||||
_T(" /? - This help.\n\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue