Solved

How to Get Registry KeyValue?

Posted on 1998-09-16
3
212 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 50 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

691 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