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 1019323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:59:42+00:00 2026-05-16T10:59:42+00:00

The following piece of code seems to unreliably execute and after and undeterministic time

  • 0

The following piece of code seems to unreliably execute and after and undeterministic time it will fail with error code 234 at the RegEnumValue function.

I have not written this code, I am merely trying to debug it. I know there is an issue with doing RegEnumValue and then deleting keys in the while loop.

I am trying to figure out first, why it is throwing this 234 error at seemingly random points, as in, it is never after a consistent number of loop iterations or anything like that.

From what I have seen it fails to fill its name buffer, but this buffer is by no means too small for its purpose, so I don’t understand how it could fail??

Could someone please advice on getting rid of this 234 error thrown by the RegEnumValue funciton?

    HKEY key;
    DWORD dw;
    int idx;
    char name[8192];
    DWORD namesize=4096;
    std::string m_path = "SOFTWARE\\Company\\Server 4.0";

    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,m_path.c_str(),0,KEY_ALL_ACCESS,&key) == ERROR_SUCCESS)
    {
        bool error=false;
        idx=0;
        long result;
        long delresult;
        while (true)
        {
            result = RegEnumValue(key,idx,(char*)name,&namesize,NULL,NULL,NULL,NULL);

            if (result == ERROR_SUCCESS && !error){

                delresult = RegDeleteValue(key,name);
                if (delresult != ERROR_SUCCESS)
                    error = true;

                idx++;
            }
            else
            {
                break;
            }
        }
        RegCloseKey(key);
    }
  • 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-05-16T10:59:43+00:00Added an answer on May 16, 2026 at 10:59 am

    There are some errors in your code:

    1. The 4-th parameter of RegEnumValue (the namesize) is in-out parameter. So you have to reset namesize to sizeof(name)/sizeof(name[0]) (in case of the usage char type it is just sizeof(name)) inside the while loop before every call of RegEnumValue. It’s the main error in your program.
    2. If you don’t want to have ERROR_MORE_DATA error any time you have the buffer having 32,767 characters. It is the maximum size of name the the regitry value (see documentation of RegEnumValue).
    3. It is not good to use KEY_ALL_ACCESS in the RegOpenKeyEx. I’ll recomend you to change it to KEY_QUERY_VALUE | KEY_SET_VALUE. It is not a real error, but depends on your environment it could be.
    4. It if better to use UNICODE version of all this functions to speed-up a little the code.

    UPDATED: Only small comment about the usage of the UNICODE version. Intern Windows work with UNICODE characters. So usage of non-Unicode version of RegEnumValue si more slow because at the evry call a new UICODE memeory block will be allocated and converted to ANSI/Multi-byte. Moreover if you will has a value name written in a language which can’t be converted in you Windows ANSI code page (Chinese, Japanese and so on) and some characters will be replaced to ‘?’ (see WC_DEFAULTCHAR flag of WideCharToMultiByte), then it can be that the function RegDeleteValue will fail with the error code like “the value with the name is not exist”.

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

Sidebar

Related Questions

The following piece of code is used to print the time in the logs:
I have the following piece of code in my Model: public function getSite() {
Consider the following piece of code: class foo { private function m() { echo
I'm using GTMLogger and have the following piece of code that seems to be
I am having a tough time understanding the following piece of code: int stride
I am trying the following piece of code in java, but it doesn't seem
the following piece of code works fine when i use it among some code
The following piece of code should read each line of the file and operate
The following piece of code runs fine when parallelized to 4-5 threads, but starts
The following piece of code is working on Android devices and iPhone simulator but

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.