Solved

RegEnumValue

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

10 Experts available now in Live!

Get 1:1 Help Now