?
Solved

How to Get Registry KeyValue?

Posted on 1998-09-16
3
Medium Priority
?
214 Views
Last Modified: 2010-04-01
How to Get Registry KeyValue by using the RegQueryValueEx api Function.

My problem is when I try to follow the syntax, it give me all I can Open the regkey but It won't return any key to me for the specified syntax for.
0
Comment
Question by:Haho2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1172929
show us your code and we will tell you where you are wrong.
0
 

Accepted Solution

by:
schmid earned 200 total points
ID: 1172930
I use this function like this:

  LPCSTR lpszKey = "SOFTWARE\\MyProgram";
  HKEY hKey = NULL;
  LONG lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpszKey, 0, KEY_READ,
                              &hKey);
  if (lResult != ERROR_SUCCESS)
  {
    AfxMessageBox("Failed to access registry!");
    AfxAbort();
  }

  DWORD nEntryType = 0;
  DWORD nDataSize = 255;
  BYTE szPath [255];
  lResult = RegQueryValueEx(hKey, "Path", NULL,
                            &nEntryType, szPath, &nDataSize);
  if (lResult != ERROR_SUCCESS)
  {
    AfxMessageBox("Failed to access registry!");
    AfxAbort();
  }
  else
  {
    strcpy(Path, (const char*) szPath);
  }


Regards,
Marc Schmid
0
 

Author Comment

by:Haho2
ID: 1172931
I have solved the program and thanks for your code... :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question