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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
You can use the RegQueryValue() or RegQueryValueEx() functions.

Let me know if you have any questions.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.