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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:46:13+00:00 2026-05-14T19:46:13+00:00

DWORD type = REG_NONE; int i = 0; size = sizeof(ValueName); size2 = sizeof(ValueData);

  • 0
 DWORD type = REG_NONE;
 int i = 0;
 size = sizeof(ValueName);
 size2 = sizeof(ValueData);
 BOOL bContinue = TRUE;

 do
 {
  lRet = RegEnumValue(Hkey , i , ValueName , &size , 0 , &type , ValueData , &size2);
  switch(lRet)
  {
  case ERROR_SUCCESS:
   print_values(ValueName , type , ValueData , size2);
   i++;
   size = sizeof(ValueName);
   size2 = sizeof(ValueData);
   break;
  case ERROR_MORE_DATA:
   size2 = sizeof(ValueData);
   if(NULL != ValueData) delete [] ValueData;
   ValueData = new BYTE[size2];
   break;
  case ERROR_NO_MORE_ITEMS:
   bContinue = false;
   break;
  default:
   cout << "Unexpected error: " << GetLastError() << endl;
   bContinue = false;
   break;
  }
 }while(bContinue);

it always goes to ERROR_NO_MORE_DATA ,why is that ? :-/

EDIT:

sorry,i ment : ERROR_MORE_DATA:) i changed something,still doesnt work

class Registry {
public:
    Registry();
    ~Registry();
    bool open_key_ex(HKEY hkey, const char * key, HKEY & hkey_out);
    void querry_info_key(HKEY);
    void enum_key(HKEY , DWORD);
    void enum_value(HKEY);
    void print_values(LPCSTR , DWORD , LPBYTE , DWORD);
    void run();
private:
    HKEY hkey;
    long lRet;
    FILETIME filetime;
    DWORD sub_keys;
    TCHAR* ValueName;
    DWORD size;
    LPBYTE ValueData;
    DWORD size2;
    HKEY a;
    DWORD MaxValueLen;
    DWORD MaxDataLen;

};

Registry::Registry()
{
    ValueName = new TCHAR[MAX_PATH];
    ValueData = NULL;
    MaxValueLen = MAX_PATH + 1;
    MaxDataLen = 0;
}

Registry::~Registry()
{
    delete [] ValueName;
}

void Registry::enum_value(HKEY Hkey)
{
    DWORD type = REG_NONE;
    int i = 0;
    size2 = MaxDataLen;
    BOOL bContinue = TRUE;

    do
    {
        lRet = RegEnumValue(Hkey , i , ValueName , &size , 0 , &type , ValueData , &size2);
        size = MaxValueLen;
        switch(lRet)
        {
        case ERROR_SUCCESS:
            print_values(ValueName , type , ValueData , size2);
            size2 = MaxDataLen;
            i++;
            break;
        case ERROR_MORE_DATA:
            MaxDataLen = size2;
            if(NULL != ValueData) delete [] ValueData;
            ValueData = new BYTE[MaxDataLen];
            break;
        case ERROR_NO_MORE_ITEMS:
            bContinue = false;
            break;
        default:
            cout << "Unexpected error: " << GetLastError() << endl;
            bContinue = false;
            break;
        }
    }while(bContinue);
}
  • 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-14T19:46:13+00:00Added an answer on May 14, 2026 at 7:46 pm

    I suspect it’s related to this:

    size2 = sizeof(ValueData);
    

    Although I don’t see a declaration for ValueData, it’s apparent that it is a pointer, not an array. Therefore, sizeof will give you the size of a pointer rather than the size of the buffer it points to. You’ll need to keep track of the size yourself. The same might be true of ValueName, but I can’t tell.

    From http://msdn.microsoft.com/en-us/library/ms724865%28VS.85%29.aspx:

    If the buffer specified by lpData is
    not large enough to hold the data, the
    function returns ERROR_MORE_DATA and
    stores the required buffer size in the
    variable pointed to by lpcbData. In
    this case, the contents of lpData are
    undefined.

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

Sidebar

Related Questions

I have a thread with return type DWORD in C but it is then
windows.h is included, code: #include <windows.h> int main() { HANDLE hToken; DWORD dwSize; TOKEN_ELEVATION_TYPE
I want to do WriteProcessMemory In C++ using Dword or Int, without storing it
I have the following struct john { int oldA; int A; } myJohn; DWORD
I've run into a strange problem: when setting values of the DWORD type in
I'm trying to create a DWORD registry key by setting Type to dword .
String* Adder::downloadUrl(String* url) { DWORD dwSize = 0; LPVOID lpOutBuffer = NULL; BOOL bResults
I have a reg file which I'm trying to read. There's a type dword
type myrec = record id:dWord; name:array[0..31] of WideChar; three:dword; count:dword; ShuXing:Single; ShuXing2:dword; ShuXing3:dWORD; end;
I have 2 assembly methods: DWToHex PROTO:DWORD modifies binary integer number of type DWORD

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.