Solved

How to Get Registry KeyValue?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to copy an image file into clipboard C/C++? 1 168
GUI: DIalog Stacking and Popping in MS C++ 4 74
Dialogbox API leak? 18 94
Error creating a new C++ project in ,net 20 33
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 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 how to clear a vector as well as how to detect empty vectors in C++.

776 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