hey everyone im making an gui in C++ which needs to retrieve windows registrys such as windows version etc. however im stuck on some code i was hoping for some help please.

void GetSystemInformation(void)
{
	float fprocessor;
	HKEY hKey;
	DWORD processorspeed;
	DWORD datasize;

	RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Hardware\\Description\\System\\CentralProcessor\\0",0, KEY_QUERY_VALUE,&hKey);
	RegQueryValueEx(hKey,("~MHz"),NULL,NULL,(LPBYTE)&processorspeed,&datasize);

	fprocessor=float(processorspeed);

	if (fprocessor>1000)
	 sprintf(processorspeed,"%3.1f Ghz",fprocessor/1000);
	else
     sprintf(processorspeed,"%3.1f Mhz",fprocessor);
}

that is my function however i get a error which is error C2664: 'sprintf' : cannot convert parameter 1 from 'DWORD' to 'char *' i cant find what the problem is cause the teacher said sprintf should get it to work and now i cant get in touch with my teacher so all help will be much apperciated. also if anyone knows a site which will help me get more sample code for any registry calls such as windows version,computer name etc can you please let me know thanks

sprintf expects a char* as the first parameter; it is where it will store the output, as a string of characters.

I don't know what you actually want to do, but if you want to see that it's working, try the following lines (instead of the sprintf lines above):

if (fprocessor>1000)
	 printf("%3.1f Ghz",fprocessor/1000);
	else
     printf("%3.1f Mhz",fprocessor);

This will print the info to the console. If you wanted to return the string from the function, you would have to change the function return type, or parameter list.

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.