DWORD type = REG_NONE;
int i = 0;
size = sizeof(ValueName);
size2 = sizeof(ValueData);
BOOL bContinue = TRUE;
do
{
lRet = RegEnumValue(Hkey , i , ValueName , &size , 0 , &type , ValueData , &size2);
switch(lRet)
{
case ERROR_SUCCESS:
print_values(ValueName , type , ValueData , size2);
i++;
size = sizeof(ValueName);
size2 = sizeof(ValueData);
break;
case ERROR_MORE_DATA:
size2 = sizeof(ValueData);
if(NULL != ValueData) delete [] ValueData;
ValueData = new BYTE[size2];
break;
case ERROR_NO_MORE_ITEMS:
bContinue = false;
break;
default:
cout << "Unexpected error: " << GetLastError() << endl;
bContinue = false;
break;
}
}while(bContinue);
it always goes to ERROR_NO_MORE_DATA ,why is that ? :-/
EDIT:
sorry,i ment : ERROR_MORE_DATA:) i changed something,still doesnt work
class Registry {
public:
Registry();
~Registry();
bool open_key_ex(HKEY hkey, const char * key, HKEY & hkey_out);
void querry_info_key(HKEY);
void enum_key(HKEY , DWORD);
void enum_value(HKEY);
void print_values(LPCSTR , DWORD , LPBYTE , DWORD);
void run();
private:
HKEY hkey;
long lRet;
FILETIME filetime;
DWORD sub_keys;
TCHAR* ValueName;
DWORD size;
LPBYTE ValueData;
DWORD size2;
HKEY a;
DWORD MaxValueLen;
DWORD MaxDataLen;
};
Registry::Registry()
{
ValueName = new TCHAR[MAX_PATH];
ValueData = NULL;
MaxValueLen = MAX_PATH + 1;
MaxDataLen = 0;
}
Registry::~Registry()
{
delete [] ValueName;
}
void Registry::enum_value(HKEY Hkey)
{
DWORD type = REG_NONE;
int i = 0;
size2 = MaxDataLen;
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);
}