here is my code:

TCHAR name[MAX_PATH];
	DWORD size;
	BYTE name2[MAX_PATH];
	DWORD size2;

int i = 0;
	while(RegEnumValue(Hkey , i , name , &size , 0 , NULL , name2 , &size2) != ERROR_NO_MORE_ITEMS)
	{
		cout << "Value name: " << name << "---" << "Data name: " << name2 << endl;
		i++;
		size = sizeof(name);
		size2 = sizeof(name2);

the problem is that is printing the values,but not the data they are containing....something like:

Value name: ColorTable01---Data name: 
Value name: ColorTable02---Data name: 
Value name: ColorTable03---Data name: 
Value name: ColorTable04---Data name: €
Value name: ColorTable05---Data name: €
Value name: ColorTable06---Data name: €€
Value name: ColorTable07---Data name: ŔŔŔ
Value name: ColorTable08---Data name: €€€

Did you use regedit program to view the contents of those data items? Are they strings or something else, such as integers? My guess is that your program needs to check the data type and make appropriate cast before attempting to display them.

Also check if strings are null terminated. From MSDN

If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, the string may not have been stored with the proper null-terminating characters. Therefore, even if the function returns ERROR_SUCCESS, the application should ensure that the string is properly terminated before using it; otherwise, it may overwrite a buffer. (Note that REG_MULTI_SZ strings should have two null-terminating characters.)

ok..for example if the type is a REG_DWORD,how can i display it corectly? i need to cast? if so,can you tell mey how,because is not working for me :(

cout << "Value name: " << name << "---" << "Data name: " << *(DWORD *)name2 << endl; As I said you will have to type cast the BYTE* into DWORD*

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.