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() api issue.

RegOpenKeyEx() api issue.

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadminwindows-adminjson
9 Posts 4 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.
  • B Offline
    B Offline
    birajendu
    wrote on last edited by
    #1

    I have to open a registry key whose length is more than 255 charecter length. I have called RegOpenKeyEx() function to open the key. But it failed. i came to know that i can call this function recussively to open such keys of long path.But the 1st call only succeed. code piece: DWORD status = RegOpenKeyEx( HKEY_CURRENT_USER , L"SOFTWARE\xyz\Connections\\properties\", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey ); in next call DWORD status = RegOpenKeyEx( hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, subkeyhKey ); the 2nd call failed. giving error no 6. the actuall key is SOFTWARE\xyz\Connections\<GUID>\properties\Fallback\server\item can you help me out to fix this.... thanks in advance....

    Birajendu SonicWALL Bangalore India

    C L K 3 Replies Last reply
    0
    • B birajendu

      I have to open a registry key whose length is more than 255 charecter length. I have called RegOpenKeyEx() function to open the key. But it failed. i came to know that i can call this function recussively to open such keys of long path.But the 1st call only succeed. code piece: DWORD status = RegOpenKeyEx( HKEY_CURRENT_USER , L"SOFTWARE\xyz\Connections\\properties\", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey ); in next call DWORD status = RegOpenKeyEx( hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, subkeyhKey ); the 2nd call failed. giving error no 6. the actuall key is SOFTWARE\xyz\Connections\<GUID>\properties\Fallback\server\item can you help me out to fix this.... thanks in advance....

      Birajendu SonicWALL Bangalore India

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      birajendu wrote:

      i came to know that i can call this function recussively

      Do you mean iteratively? :-D

      birajendu wrote:

      DWORD status = RegOpenKeyEx( hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, subkeyhKey );

      shouldn't be

      DWORD status = RegOpenKeyEx(
      hKey ,
      L"Fallback\server\item",
      0,
      KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
      &subkeyhKey
      );
      ?

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      B 1 Reply Last reply
      0
      • C CPallini

        birajendu wrote:

        i came to know that i can call this function recussively

        Do you mean iteratively? :-D

        birajendu wrote:

        DWORD status = RegOpenKeyEx( hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, subkeyhKey );

        shouldn't be

        DWORD status = RegOpenKeyEx(
        hKey ,
        L"Fallback\server\item",
        0,
        KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
        &subkeyhKey
        );
        ?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        B Offline
        B Offline
        birajendu
        wrote on last edited by
        #3

        CPallini wrote:

        DWORD status = RegOpenKeyEx(hKey ,L"Fallback\server\item",0,KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,&subkeyhKey);

        Sorry it was a typo... I am using like this only. status = RegOpenKeyEx(hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &subkeyhKey); Still the same error...

        Birajendu SonicWALL Bangalore India

        C 1 Reply Last reply
        0
        • B birajendu

          I have to open a registry key whose length is more than 255 charecter length. I have called RegOpenKeyEx() function to open the key. But it failed. i came to know that i can call this function recussively to open such keys of long path.But the 1st call only succeed. code piece: DWORD status = RegOpenKeyEx( HKEY_CURRENT_USER , L"SOFTWARE\xyz\Connections\\properties\", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey ); in next call DWORD status = RegOpenKeyEx( hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, subkeyhKey ); the 2nd call failed. giving error no 6. the actuall key is SOFTWARE\xyz\Connections\<GUID>\properties\Fallback\server\item can you help me out to fix this.... thanks in advance....

          Birajendu SonicWALL Bangalore India

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

          birajendu wrote:

          L"SOFTWARE\xyz\Connections\\properties\"

          You have a field <GUID> missing here according to your later description of the key content.

          1 Reply Last reply
          0
          • B birajendu

            CPallini wrote:

            DWORD status = RegOpenKeyEx(hKey ,L"Fallback\server\item",0,KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,&subkeyhKey);

            Sorry it was a typo... I am using like this only. status = RegOpenKeyEx(hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &subkeyhKey); Still the same error...

            Birajendu SonicWALL Bangalore India

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #5

            Since error code 6 is 'invalid handle', what is the value of the status variable immediately after the first previous call? :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            B 1 Reply Last reply
            0
            • C CPallini

              Since error code 6 is 'invalid handle', what is the value of the status variable immediately after the first previous call? :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              B Offline
              B Offline
              birajendu
              wrote on last edited by
              #6

              Value of Status variable is only 6, error i got from Getlasterror() is 0.

              Birajendu SonicWALL Bangalore India

              C 1 Reply Last reply
              0
              • B birajendu

                Value of Status variable is only 6, error i got from Getlasterror() is 0.

                Birajendu SonicWALL Bangalore India

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                Immediately after the first RegOpenKeyEx call is 6? :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                B 1 Reply Last reply
                0
                • C CPallini

                  Immediately after the first RegOpenKeyEx call is 6? :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  B Offline
                  B Offline
                  birajendu
                  wrote on last edited by
                  #8

                  After 2nd call of RegOpenKeyEx().

                  Birajendu SonicWALL Bangalore India

                  1 Reply Last reply
                  0
                  • B birajendu

                    I have to open a registry key whose length is more than 255 charecter length. I have called RegOpenKeyEx() function to open the key. But it failed. i came to know that i can call this function recussively to open such keys of long path.But the 1st call only succeed. code piece: DWORD status = RegOpenKeyEx( HKEY_CURRENT_USER , L"SOFTWARE\xyz\Connections\\properties\", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey ); in next call DWORD status = RegOpenKeyEx( hKey , L"Fallback\server\item", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, subkeyhKey ); the 2nd call failed. giving error no 6. the actuall key is SOFTWARE\xyz\Connections\<GUID>\properties\Fallback\server\item can you help me out to fix this.... thanks in advance....

                    Birajendu SonicWALL Bangalore India

                    K Offline
                    K Offline
                    krmed
                    wrote on last edited by
                    #9

                    It appears no one has mentioned it yet, but you need to use double backslashes. Instead of

                    L"SOFTWARE\xyz\Connections\\properties\"

                    you should use

                    L"SOFTWARE\\xyz\\Connections\\properties\\"

                    Hope that helps.

                    Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                    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