| | |
Help Please Win32
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 29
Reputation:
Solved Threads: 0
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.
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
C++ Syntax (Toggle Plain Text)
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
Last edited by Superstar288; Nov 28th, 2008 at 7:49 pm.
•
•
Join Date: Jun 2007
Posts: 275
Reputation:
Solved Threads: 45
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):
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.
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):
c Syntax (Toggle Plain Text)
if (fprocessor>1000) printf("%3.1f Ghz",fprocessor/1000); else printf("%3.1f Mhz",fprocessor);
Last edited by dougy83; Nov 28th, 2008 at 10:33 pm.
![]() |
Similar Threads
- Creating A Table With Win32 Api (C++)
- I NEED HELP WITH "Generic Host Process for Win32 Services ERROR" (Viruses, Spyware and other Nasties)
- Generic Host Process for Win32 Services (Viruses, Spyware and other Nasties)
- Writing a Win32 DLL in VC++ (C++)
- Socket programming + porting Unix to Win32 (C)
- Question regarding reading from registry (Win32) VC6 (C++)
- Can you add pictures/sounds in a win32 console app? (C)
- Displaying a different bitmap in different child windows? - win32 in C (C)
Other Threads in the C++ Forum
- Previous Thread: Rational Number Class
- Next Thread: const_reverse_iterator vs vec.rend()
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





