Solved

How to Get Registry KeyValue?

Posted on 1998-09-16
3
198 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
3 Comments
 
LVL 7

Expert Comment

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

Accepted Solution

by:
schmid earned 50 total points
Comment Utility
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
Comment Utility
I have solved the program and thanks for your code... :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now