Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ERROR_MORE_DATA on RegQueryValueEx()

ERROR_MORE_DATA on RegQueryValueEx()

Scheduled Pinned Locked Moved C / C++ / MFC
helpwindows-adminquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KingTermite
    wrote on last edited by
    #1

    Playing around with some registry stuff.... I'm making a call to RegQueryValueEx() with the returnstring buffer that is 4K. I am continually getting a system error code of ERROR_MORE_DATA. When I look at the data in the dubugger, it's about 400 characters. Could there be another problem that would give that error code?


    There are only 10 types of people in this world....those that understand binary, and those that do not.

    K B 2 Replies Last reply
    0
    • K KingTermite

      Playing around with some registry stuff.... I'm making a call to RegQueryValueEx() with the returnstring buffer that is 4K. I am continually getting a system error code of ERROR_MORE_DATA. When I look at the data in the dubugger, it's about 400 characters. Could there be another problem that would give that error code?


      There are only 10 types of people in this world....those that understand binary, and those that do not.

      K Offline
      K Offline
      KingTermite
      wrote on last edited by
      #2

      Nobody has seen this or had this problem? :(


      There are only 10 types of people in this world....those that understand binary, and those that do not.

      1 Reply Last reply
      0
      • K KingTermite

        Playing around with some registry stuff.... I'm making a call to RegQueryValueEx() with the returnstring buffer that is 4K. I am continually getting a system error code of ERROR_MORE_DATA. When I look at the data in the dubugger, it's about 400 characters. Could there be another problem that would give that error code?


        There are only 10 types of people in this world....those that understand binary, and those that do not.

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        Maybe you did not fill in the buffer size on input? You need to tell it how big your buffer is, or else you would be getting that error. If you still have troubles, post a few lines of your code setting up your data before and during call to functiona nd we cna help you figure it out. In other words, not in about 12 years of writing Widnows software have I EVER got that error code back from RegQueryValue unexpectedly. When I do get it bakc, it is because I am testing how large the value's data is and will then allocate a large enough buffer during a subsequent call. From MSDN: lpcbValue [in, out] Pointer to a variable that specifies the size of the buffer pointed to by the lpValue parameter, in bytes. When the function returns, this variable contains the size of the data copied to lpValue, including any terminating null characters. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes any terminating null character or characters. For more information, see Remarks. If the buffer specified lpValue 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 lpcbValue. In this case, the contents of the lpValue buffer are undefined.

        K 1 Reply Last reply
        0
        • B Blake Miller

          Maybe you did not fill in the buffer size on input? You need to tell it how big your buffer is, or else you would be getting that error. If you still have troubles, post a few lines of your code setting up your data before and during call to functiona nd we cna help you figure it out. In other words, not in about 12 years of writing Widnows software have I EVER got that error code back from RegQueryValue unexpectedly. When I do get it bakc, it is because I am testing how large the value's data is and will then allocate a large enough buffer during a subsequent call. From MSDN: lpcbValue [in, out] Pointer to a variable that specifies the size of the buffer pointed to by the lpValue parameter, in bytes. When the function returns, this variable contains the size of the data copied to lpValue, including any terminating null characters. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes any terminating null character or characters. For more information, see Remarks. If the buffer specified lpValue 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 lpcbValue. In this case, the contents of the lpValue buffer are undefined.

          K Offline
          K Offline
          KingTermite
          wrote on last edited by
          #4

          Blake Miller wrote: Maybe you did not fill in the buffer size on input? Thank you. I feel so stupid. I had this working before, but then copy/pasted the code to create a library. I left that var at 0 and was thinking that was the size of the data returned, not for "me" to fill out.


          There are only 10 types of people in this world....those that understand binary, and those that do not.

          B 1 Reply Last reply
          0
          • K KingTermite

            Blake Miller wrote: Maybe you did not fill in the buffer size on input? Thank you. I feel so stupid. I had this working before, but then copy/pasted the code to create a library. I left that var at 0 and was thinking that was the size of the data returned, not for "me" to fill out.


            There are only 10 types of people in this world....those that understand binary, and those that do not.

            B Offline
            B Offline
            Blake Miller
            wrote on last edited by
            #5

            When the function returns, the 'size' variable will have a numeric value the size of the data stored to the buffer. If you ever use something like this in a loop, you need to remember to reset the variable to the size of your buffer before calling RegQueryValue each time. It is sometimes easy to overlook the [in, out] specification on a parameter :doh:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups