Help Please Win32

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 29
Reputation: Superstar288 is an unknown quantity at this point 
Solved Threads: 0
Superstar288 Superstar288 is offline Offline
Light Poster

Help Please Win32

 
0
  #1
Nov 28th, 2008
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.
  1. void GetSystemInformation(void)
  2. {
  3. float fprocessor;
  4. HKEY hKey;
  5. DWORD processorspeed;
  6. DWORD datasize;
  7.  
  8. RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Hardware\\Description\\System\\CentralProcessor\\0",0, KEY_QUERY_VALUE,&hKey);
  9. RegQueryValueEx(hKey,("~MHz"),NULL,NULL,(LPBYTE)&processorspeed,&datasize);
  10.  
  11. fprocessor=float(processorspeed);
  12.  
  13. if (fprocessor>1000)
  14. sprintf(processorspeed,"%3.1f Ghz",fprocessor/1000);
  15. else
  16. sprintf(processorspeed,"%3.1f Mhz",fprocessor);
  17. }

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
Last edited by Superstar288; Nov 28th, 2008 at 7:49 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 275
Reputation: dougy83 is on a distinguished road 
Solved Threads: 45
dougy83 dougy83 is offline Offline
Posting Whiz in Training

Re: Help Please Win32

 
0
  #2
Nov 28th, 2008
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):
  1. if (fprocessor>1000)
  2. printf("%3.1f Ghz",fprocessor/1000);
  3. else
  4. 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.
Last edited by dougy83; Nov 28th, 2008 at 10:33 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC