Solved

RegEnumValue

Posted on 1998-05-06
2
527 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
2 Comments
 

Author Comment

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

Accepted Solution

by:
mikeblas earned 50 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 169
WinWaitActive parameters 12 31
Problem to Office 1 43
Adjust the codes 3 30
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

749 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