• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

How to Get Registry KeyValue?

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
Haho2
Asked:
Haho2
1 Solution
 
fasterCommented:
show us your code and we will tell you where you are wrong.
0
 
schmidCommented:
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
 
Haho2Author Commented:
I have solved the program and thanks for your code... :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now