36 #define _ui64tot _ui64tow
38 #define _ui64tot _ui64toa
43#define DIR_CMD _T("DIR")
44#define DIR_CMD_LENGTH COMMAND_LENGTH(DIR_CMD)
45#define DIR_CMD_SHORT_DESC DIR_CMD _T(" command lists keys and values of any key.\n")
89 goto CheckDirArgument;
95 blnBadParameter =
FALSE;
100 blnDo = pszKey !=
NULL;
104 pszKey = pszParameter;
109 blnBadParameter =
TRUE;
113 rConsole.
Write(
_T(
"Bad parameter: "));
114 rConsole.
Write(pszParameter);
120 const TCHAR *pszPath =
_T(
".");
133 if (*
pch !=
_T(
'\\'))
135 while ((
pch > pszKey) && (*
pch !=
_T(
'\\')))
138 if (*
pch ==
_T(
'\\'))
147 else if (*
pch ==
_T(
'\\'))
165 rConsole.
Write(pszErrorMsg);
179 rConsole.
Write(
_T(
"\n Key is "));
184 rConsole.
Write(
_T(
"\n Last modify time is "));
185 rConsole.
Write(
Key.GetLastWriteTime());
189 unsigned __int64 nTotalItems = 0;
194 rConsole.
Write(
_T(
"\t(KEY)\t\t\t\t..\\\n"));
197 DWORD dwMaxSubkeyNameLength;
198 nError =
Key.GetSubkeyNameMaxLength(dwMaxSubkeyNameLength);
202 TCHAR *pszSubkeyNameBuffer =
new (std::nothrow)
TCHAR[dwMaxSubkeyNameLength];
203 if (!pszSubkeyNameBuffer)
206 Key.InitSubkeyEnumeration(pszSubkeyNameBuffer,dwMaxSubkeyNameLength);
211 rConsole.
Write(
_T(
"\t(KEY)\t\t\t\t"));
212 rConsole.
Write(pszSubkeyNameBuffer);
218 delete[] pszSubkeyNameBuffer;
223 DWORD dwMaxValueNameBufferSize;
224 nError =
Key.GetMaxValueNameLength(dwMaxValueNameBufferSize);
228 TCHAR *pchValueNameBuffer =
new (std::nothrow)
TCHAR[dwMaxValueNameBufferSize];
229 if (!pchValueNameBuffer)
234 Key.InitValueEnumeration(pchValueNameBuffer,
235 dwMaxValueNameBufferSize,
240 DWORD dwValueNameActualLength;
241 const TCHAR *pszValueTypeName;
244 while((nError =
Key.GetNextValue(&dwValueNameActualLength)) ==
ERROR_SUCCESS)
250 nTabs =
_tcslen(pszValueTypeName)/nTabSize;
251 nTabs = (nTabs < 4)?(4-nTabs):1;
252 rConsole.
Write(pszValueTypeName);
255 rConsole.
Write((dwValueNameActualLength == 0)?
_T(
"(Default)"):pchValueNameBuffer);
261 delete[] pchValueNameBuffer;
275 rConsole.
Write(
_T(
"\n Total: "));
278 rConsole.
Write(
_T(
" item(s) listed.\n"));
286 _T(
"Syntax: ")
DIR_CMD _T(
" [<PATH>\\][<PATTERN>] [/?]\n\n")
287 _T(
" <PATH> - Optional relative path to the key on which command will be executed\n")
288 _T(
" <PATTERN> - Optional pattern. Default is the all matching pattern.")
289 _T(
" /? - This help.\n\n")
290 _T(
"Without parameters, command lists keys and values of current key.\n");
BOOL PatternMatch(const TCHAR *pszPattern, const TCHAR *pszTry)
#define PATTERN_MATCH_ALL
#define DIR_CMD_SHORT_DESC
void ResetArgumentIteration()
TCHAR * GetNextArgument()
unsigned int GetTabWidth()
BOOL Write(const TCHAR *p, DWORD dwChars=0)
static const TCHAR * GetValueTypeName(DWORD dwType)
BOOL GetKey(const TCHAR *pchRelativePath, REGSAM DesiredAccess, CRegistryKey &rKey)
const TCHAR * GetLastErrorDescription()
virtual int Execute(CConsole &rConsole, CArgumentParser &rArguments)
virtual BOOL Match(const TCHAR *pchCommand)
CShellCommandDir(CRegistryTree &rTree)
virtual ~CShellCommandDir()
virtual const TCHAR * GetHelpShortDescriptionString()
virtual const TCHAR * GetHelpString()
#define ERROR_NO_MORE_ITEMS
_CRTIMP char *__cdecl _itoa(_In_ int _Value, _Pre_notnull_ _Post_z_ char *_Dest, _In_ int _Radix)
#define KEY_ENUMERATE_SUB_KEYS