Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:30:47+00:00 2026-06-14T06:30:47+00:00

I am working on the code in wherin i have to get the data

  • 0

I am working on the code in wherin i have to get the data under the particular regitry path..For this i m using the fnctions to open the key and subkey as
RegOpenKeyEx (HKEY_LOCAL_MACHINE, sk, NULL, KEY_READ, &hKey);
which on debugging giving me unused value handle to the path i need to access.
What is going wrong here ? can anybody tell me ?

void GetAlgorithmList()
{
    HKEY hKey=0;

    LPCTSTR sk = TEXT("SOFTWARE\\ALGORITHM");


    LONG openRes=RegOpenKeyEx (HKEY_LOCAL_MACHINE,sk,NULL,KEY_READ   ,&hKey);

    long lret;
    PVALENT val_list=0;

    unsigned long totalsize = 1000;
    lret = 0;

    LPWSTR szValueBuf=NULL;

    lret = RegQueryMultipleValues(hKey,val_list,totalsize,szValueBuf,&totalsize);
    if (lret == ERROR_SUCCESS)
    {
        printf("Success 1");
    }
     FILE* pFile = fopen("D:\\HinalH\\logFile.txt", "a+");
    fopen("D:\\logFile.txt", "a+");
    fprintf(pFile, "%d\n",szValueBuf);
    fclose(pFile);

    RegCloseKey(hKey);

}

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:30:48+00:00Added an answer on June 14, 2026 at 6:30 am

    First: You should check the result of RegOpenKeyEx. Please read the documentation more carefully. Its really necessary to handle errors if they occur at runtime.

    Second: Please take a look to the documentation for function RegQueryMultipleValues.
    Just take your attention to the val_list parameter and to the lpValueBuf parameter both are out parameter. I cannot see that you handle them in the right way in your code.

    Third: I cannot find any sample using RegQueryMultipleValues in the web. I played a little arround and created a working example.

    Here is the sample I did.

    #include <Windows.h>
    #include <string>
    #include <stdlib.h>
    
    #define MY_KEY TEXT("SYSTEM\\CurrentControlSet\\services\\BITS")
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        HKEY hKey;
        LONG lResult;
    
        lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, MY_KEY, 0, KEY_READ, &hKey);
    
        if(lResult == ERROR_SUCCESS)
        {
            VALENT val_list[4];
            memset(val_list, 0, sizeof(val_list));
    
            val_list[0].ve_valuename = TEXT("ImagePath");
            val_list[1].ve_valuename = TEXT("Start");
            val_list[2].ve_valuename = TEXT("DisplayName");
            val_list[3].ve_valuename = TEXT("FailureActions");
    
            DWORD totalsize = 0;
    
            RegQueryMultipleValues(hKey, val_list, sizeof(val_list)/sizeof(VALENT), NULL, &totalsize);
    
            LPWSTR lpBuffer = (LPWSTR)malloc(totalsize);
            if (lpBuffer == NULL)
            {
                // TODO: Error handling
            }
    
            lResult = RegQueryMultipleValues(hKey, val_list, sizeof(val_list)/sizeof(VALENT), lpBuffer, &totalsize);
            if (lResult == ERROR_SUCCESS)
            {
                for (int i = 0; i < sizeof(val_list)/sizeof(VALENT); i++)
                {
                    DWORD len = val_list[i].ve_valuelen;
                    DWORD *ptr = (DWORD *)val_list[i].ve_valueptr;
    
                    if (val_list[i].ve_type == REG_SZ || val_list[i].ve_type == REG_EXPAND_SZ)
                    {
                        printf("len:%d content:\"%S\"\n", len, ptr);
                    }
                    else if (val_list[i].ve_type == REG_DWORD)
                    {
                        printf("len:%d content:\"%08x\"\n", len, *ptr);
                    }
                    else if (val_list[i].ve_type == REG_BINARY)
                    {
                        printf("len:%d\n", len);
                        for (unsigned k = 0; k < len; k++) printf("%02x ", ((BYTE *)ptr)[k]);
                    }
                    else
                    {
                        // TODO: implement more
                    }
                }
            }
    
            free(lpBuffer);
            RegCloseKey(hKey);
        }
        else
        {
            // TODO: Error handling
        }
    
        return 0;
    }
    

    To be honest for me it seems this function is not the best option to access information in the registry. Better you should use functions like RegQueryValueEx.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this working code, but now i need to be able to change
As a beginner in Ocaml, I have this current working code: ... let ch_in
This is the working code, but i want to know without using another object(commented
This working code is using Sproutcore: person = SC.Object.create({ firstName: 'Foo', lastName: 'Bar', fullName:
I have taken the working code from this thread: Creating Next and Previous buttons
So I have working code that animates a BG image via a plugin. This
I have this working code from this link , to upload a file to
I'm porting some (working) code from Linux to Windows 8. I'm using DDK. typedef
I have working code of js, it shows different div for selected option. <html>
I have some working code with a crutch to add BOM marker to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.