void Registry::print_keys(LPCSTR Value , DWORD index)
{
if(index == 0)
{
cout << "----==== ENUMERATING KEYS FOR:" << Value << "====----" << endl;
}
cout << index << ":" << ValueName << endl;
}
void Registry::enum_key(HKEY Hkey , DWORD level)
{
FILETIME filetime;
int i = 0;
size = MaxValueLen;
BOOL bContinue = TRUE;
do
{
lRet = RegEnumKeyEx(Hkey , i , ValueName , &size , 0 , 0 , 0 , &filetime);
switch(lRet)
{
case ERROR_SUCCESS:
print_keys(ValueName , i);
//enum_value(Hkey);
i++;
size = MaxValueLen;
HKEY subhkey;
if(open_key_ex(Hkey , ValueName, subhkey))
{
enum_key(subhkey , level + 1);
RegCloseKey(subhkey);
}
break;
case ERROR_MORE_DATA:
size = MaxValueLen;
if(NULL != ValueName) delete [] ValueName;
ValueName = new TCHAR[size];
break;
case ERROR_NO_MORE_ITEMS:
bContinue = false;
break;
default:
cout << "Unexpected error: " << GetLastError() << endl;
bContinue = false;
break;
}
}while(bContinue);
}
void Registry::enum_value(HKEY Hkey)
{
DWORD type = REG_NONE;
int i = 0;
BOOL bContinue = TRUE;
do
{
lRet = RegEnumValue(Hkey , i , ValueName , &size , 0 , &type , ValueData , &size2);
size = MaxValueLen;
switch(lRet)
{
case ERROR_SUCCESS:
print_values(ValueName , type , ValueData , size2);
size2 = MaxDataLen;
i++;
break;
case ERROR_MORE_DATA:
MaxDataLen = size2;
if(NULL != ValueData) delete [] ValueData;
ValueData = new BYTE[MaxDataLen];
break;
case ERROR_NO_MORE_ITEMS:
bContinue = false;
break;
default:
cout << "Unexpected error: " << GetLastError() << endl;
bContinue = false;
break;
}
}while(bContinue);
}
where can i call enum_value() to display them corectly ? thanx

New Topic/Question
Reply




MultiQuote




|