INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...I have tons of books, have book marked tons of tutorials, which have helped, but this forum has answered those "impossible to find" solutions. I am thrilled with this site..."
Geography
Where in the world do Tek-Tips members come from?
|
Microsoft: Visual C++ FAQ
|
Registry Handling
|
How to read values of the system's registry
Posted: 18 Feb 04
|
Hi all,
Here is a small piece of code that reads any key/value from registry. This program will compile right away (Win32), tested on VC++6.0 .
#include "windows.h" #include <winreg.h> #include <stdio.h>
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HKEY keyHandle; char rgValue [1024]; char fnlRes [1024]; DWORD size1; DWORD Type;
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion",0, KEY_QUERY_VALUE, &keyHandle) == ERROR_SUCCESS) { size1=1023; RegQueryValueEx( keyHandle, "Productid", NULL, &Type, (LPBYTE)rgValue,&size1); sprintf(fnlRes,"Product ID of your Windows system is:: %s",rgValue); } else strcpy(fnlRes,"Couldn't access system information!"); RegCloseKey(keyHandle);
MessageBox(NULL, fnlRes, "Product ID of Windows", MB_SYSTEMMODAL|MB_ICONINFORMATION);
return 0; }
I hope it helps, have fun! 
Cheers! Roy.
PS: This code snippet should be taken as a starting point, not as a final solution. |
Back to Microsoft: Visual C++ FAQ Index
Back to Microsoft: Visual C++ Forum
My FAQ Archive
Email This FAQ To A Friend |
|
 |
|