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. RegOpenKeyEx

RegOpenKeyEx

Scheduled Pinned Locked Moved C / C++ / MFC
apachewindows-adminhelpannouncement
9 Posts 5 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.
  • V Offline
    V Offline
    venkatesh52867
    wrote on last edited by
    #1

    Hi, i am trying to read registry key value the code is this unable to get key value whats wrong this code LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); if(ret == ERROR_SUCCESS) { RegQueryValueEx( hKey, "Version",NULL, 0, (BYTE*)value, &size); } MessageBox(value); RegCloseKey(keyHandle)

    _ D 2 Replies Last reply
    0
    • V venkatesh52867

      Hi, i am trying to read registry key value the code is this unable to get key value whats wrong this code LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); if(ret == ERROR_SUCCESS) { RegQueryValueEx( hKey, "Version",NULL, 0, (BYTE*)value, &size); } MessageBox(value); RegCloseKey(keyHandle)

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      What is the return value for RegQueryValueEx. You can check here[^] for the issues you can face and identify why RegQueryValueEx is failing. Below are the failure scenarios mentioned at the above location: If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is a system error code. If the lpData buffer is too small to receive the data, the function returns ERROR_MORE_DATA. If the lpValueName registry value does not exist, the function returns ERROR_FILE_NOT_FOUND.

      You talk about Being HUMAN. I have it in my name AnsHUMAN

      V 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        What is the return value for RegQueryValueEx. You can check here[^] for the issues you can face and identify why RegQueryValueEx is failing. Below are the failure scenarios mentioned at the above location: If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is a system error code. If the lpData buffer is too small to receive the data, the function returns ERROR_MORE_DATA. If the lpValueName registry value does not exist, the function returns ERROR_FILE_NOT_FOUND.

        You talk about Being HUMAN. I have it in my name AnsHUMAN

        V Offline
        V Offline
        venkatesh52867
        wrote on last edited by
        #3

        hi, return value ERROR_FILE_NOT_FOUND. but path of key correct

        D _ M 3 Replies Last reply
        0
        • V venkatesh52867

          Hi, i am trying to read registry key value the code is this unable to get key value whats wrong this code LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); if(ret == ERROR_SUCCESS) { RegQueryValueEx( hKey, "Version",NULL, 0, (BYTE*)value, &size); } MessageBox(value); RegCloseKey(keyHandle)

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          This does not explain why RegQueryValueEx() is failing, but you are displaying a value that may be invalid, and closing a key that may not have been opened. Suggest:

          if (ret == ERROR_SUCCESS)
          {
          if (RegQueryValueEx(hKey, "Version", NULL, 0, (BYTE *) value, &size) == ERROR_SUCCESS)
          MessageBox(value);

          RegCloseKey(keyHandle)
          

          }

          Does HKLM\SOFTWARE\Apache Software Foundation\Tomcat\7.0\Tomcat7 exist? What type is value?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          V 1 Reply Last reply
          0
          • D David Crow

            This does not explain why RegQueryValueEx() is failing, but you are displaying a value that may be invalid, and closing a key that may not have been opened. Suggest:

            if (ret == ERROR_SUCCESS)
            {
            if (RegQueryValueEx(hKey, "Version", NULL, 0, (BYTE *) value, &size) == ERROR_SUCCESS)
            MessageBox(value);

            RegCloseKey(keyHandle)
            

            }

            Does HKLM\SOFTWARE\Apache Software Foundation\Tomcat\7.0\Tomcat7 exist? What type is value?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            V Offline
            V Offline
            venkatesh52867
            wrote on last edited by
            #5

            ret =2 that RegOpenKeyEx returns 2 LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); this not success

            L 1 Reply Last reply
            0
            • V venkatesh52867

              hi, return value ERROR_FILE_NOT_FOUND. but path of key correct

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              venkatesh52867 wrote:

              but path of key correct

              How are you verifying this?

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              1 Reply Last reply
              0
              • V venkatesh52867

                hi, return value ERROR_FILE_NOT_FOUND. but path of key correct

                _ Offline
                _ Offline
                _AnsHUMAN_
                wrote on last edited by
                #7

                Then there might be an issue in the path you create or the value type you use.

                You talk about Being HUMAN. I have it in my name AnsHUMAN

                1 Reply Last reply
                0
                • V venkatesh52867

                  hi, return value ERROR_FILE_NOT_FOUND. but path of key correct

                  M Offline
                  M Offline
                  MicroVirus
                  wrote on last edited by
                  #8

                  Are you running a 64 bits version of Windows? For 32 bits versions running under 64 bits windows the HKEY_LOCAL_MACHINE\Software forks to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node, which could be what causes the file not found if you spelled it correctly (spaces and all).

                  1 Reply Last reply
                  0
                  • V venkatesh52867

                    ret =2 that RegOpenKeyEx returns 2 LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); this not success

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Have you run regedit to verify the exact path of the key?

                    Use the best guess

                    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