How to Read values of Registry!

I wanna have my program read values of registry. I have some Defined keys and values stored inside it.
I wanna read 2 key and their values..How can I accomplish that!!
veselAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nietodConnect With a Mentor Commented:
You can use the RegQueryValue() or RegQueryValueEx() functions.

Let me know if you have any questions.
0
 
veselAuthor Commented:
Thx for the reply. As a matter of fact I digged inside it and found how to use it! BTW I was looking for CODE....
Thx
0
 
nietodCommented:
I can provide code, but you given any details of what you want.  What is the key?  what type of data is stored with it?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
SagresCommented:
Do the values that you want to read belong to your application or some other application?

If it belongs to your app, you should use:
GetProfileInt(...),
GetProfileString(...)  to read.
WriteProfileInt(...),
WriteProfileString(...) to write to registry.

If it belongs to another app you should use the code found in:
http://www.codeguru.com/system/registry_koening.shtml
0
 
nietodCommented:
Those functions are provided for compatibility only.  Use of those functions is discouraged.
0
 
bnyCommented:
The following is the code to read a value from the registry key
HKEY_LOCAL_MACHINE/SOFTWARE/Key1.  It reads the value of "Data1" and stores in pszValue which you can pass to the function.

HKEY hRoot,hLev1,hLev2,hLev3;
DWORD iType;
DWORD Value = iSize;
strcpy(pszValue,"");
            if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE",0,KEY_ALL_ACCESS,&hRoot))
{
                  if(!RegOpenKeyEx(hRoot,"Key1",0,KEY_ALL_ACCESS,&hLev1))
{
                              RegQueryValueEx(hLev3,"Data1",0,&iType,(unsigned char*)pszValue,(LPDWORD)&Value);      
                                    RegCloseKey(hLev3);
                                    RegCloseKey(hLev2);
                                    RegCloseKey(hLev1);
                                    RegCloseKey(hRoot);
                                    return;
                        
                  
}
}
0
 
KangaRooCommented:
0
 
nietodCommented:
While we're at it, what's up with this question.  Do you still want help?
0
 
veselAuthor Commented:
I got it!! working Thx for the concern
0
All Courses

From novice to tech pro — start learning today.