ReactOS  0.4.13-dev-479-gec9c8fd
ShellCommandSetValue.cpp File Reference
#include "ph.h"
#include "ShellCommandSetValue.h"
#include "RegistryExplorer.h"
#include "RegistryTree.h"
#include "RegistryKey.h"
Include dependency graph for ShellCommandSetValue.cpp:

Go to the source code of this file.

Macros

#define SET_VALUE_CMD   _T("SV")
 
#define SET_VALUE_CMD_LENGTH   COMMAND_LENGTH(SET_VALUE_CMD)
 
#define SET_VALUE_CMD_SHORT_DESC   SET_VALUE_CMD _T(" command is used to set value.\n")
 

Functions

BOOL StringToDWORD (DWORD &rdwOut, const TCHAR *pszIn)
 

Macro Definition Documentation

◆ SET_VALUE_CMD

#define SET_VALUE_CMD   _T("SV")

Definition at line 32 of file ShellCommandSetValue.cpp.

◆ SET_VALUE_CMD_LENGTH

#define SET_VALUE_CMD_LENGTH   COMMAND_LENGTH(SET_VALUE_CMD)

Definition at line 33 of file ShellCommandSetValue.cpp.

◆ SET_VALUE_CMD_SHORT_DESC

#define SET_VALUE_CMD_SHORT_DESC   SET_VALUE_CMD _T(" command is used to set value.\n")

Definition at line 34 of file ShellCommandSetValue.cpp.

Function Documentation

◆ StringToDWORD()

BOOL StringToDWORD ( DWORD rdwOut,
const TCHAR pszIn 
)

Definition at line 36 of file ShellCommandSetValue.cpp.

37 {
38  const TCHAR *pszDigits;
39  const TCHAR *pszOctalNumbers = _T("01234567");
40  const TCHAR *pszDecimalNumbers = _T("0123456789");
41  const TCHAR *pszHexNumbers = _T("0123456789ABCDEF");
42  const TCHAR *pszNumbers;
43  unsigned int nBase = 0;
44  if (*pszIn == _T('0'))
45  {
46  if ((*(pszIn+1) == _T('x'))||((*(pszIn+1) == _T('X'))))
47  { // hex
48  nBase = 16;
49  pszDigits = pszIn+2;
50  pszNumbers = pszHexNumbers;
51  }
52  else
53  { // octal
54  nBase = 8;
55  pszDigits = pszIn+1;
56  pszNumbers = pszOctalNumbers;
57  }
58  }
59  else
60  { //decimal
61  nBase = 10;
62  pszDigits = pszIn;
63  pszNumbers = pszDecimalNumbers;
64  }
65 
66  const TCHAR *pszDigit = pszDigits;
67  pszDigit += _tcslen(pszDigit);
68 
69  DWORD nMul = 1;
70  rdwOut = 0;
71  DWORD dwAdd;
72  const TCHAR *pszNumber;
73  while (pszDigit > pszDigits)
74  {
75  pszDigit--;
76  pszNumber = _tcschr(pszNumbers,*pszDigit);
77  if (!pszNumber)
78  return FALSE; // wrong char in input string
79 
80  dwAdd = (pszNumber-pszNumbers)*nMul;
81 
82  if (rdwOut + dwAdd < rdwOut)
83  return FALSE; // overflow
84  rdwOut += dwAdd;
85 
86  if (nMul * nBase < nMul)
87  return FALSE; // overflow
88  nMul *= nBase;
89  };
90 
91  return TRUE;
92 }
#define TRUE
Definition: types.h:120
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by CShellCommandSetValue::Execute().