?
Solved

RegEnumValue

Posted on 1998-05-06
2
Medium Priority
?
532 Views
Last Modified: 2013-11-20
I just want to know the parameters declarations for the RegEnumValue function to be able to retreive values in a key. Which parameters I really need?
0
Comment
Question by:fmichaud061597
[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
2 Comments
 

Author Comment

by:fmichaud061597
ID: 1308110
Adjusted points to 50
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 200 total points
ID: 1308111
You need all of them, except for the "reserved" parameter.

Here's a sample:

// -- begin file enum.cpp --

// compile me with
//      cl enum.cpp


#include <windows.h>
#include <stdio.h>

#pragma comment(lib, "advapi32.lib")

void main()
{
   HKEY hKey;

   if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
      "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Extensions",
      0, KEY_READ, &hKey))
   {
      printf("It worked\n");

      DWORD dwIndex = 0;
      LONG lResult;

      while (1)
      {
         char szValue[1024];
         DWORD dwValueLen = sizeof(szValue) / sizeof(szValue[0]);
         BYTE bData[1024];
         DWORD dwDataLen = sizeof(bData) / sizeof(bData[0]);
         DWORD dwType;

         lResult = RegEnumValue(hKey, dwIndex, szValue, &dwValueLen,
            0, &dwType, bData, &dwDataLen);
         
         if (lResult == ERROR_SUCCESS)
         {
            printf("value name is \"%s\", ", szValue);

            if (dwType == REG_SZ)
               printf("Data is \"%s\"\n", bData);
            else if (dwType == REG_DWORD)
               printf("Data is 0x%8.8X\n", *((DWORD*) &bData));
            else
               printf("This program only supports DWORD and SZ\n");

            dwIndex++;
         }
         else
            break;
      }

      RegCloseKey(hKey);
   }

   return;
}

// -- end file enum.cpp --


.B ekiM
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 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