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 returning strange error

RegOpenKeyEx returning strange error

Scheduled Pinned Locked Moved C / C++ / MFC
questionwindows-adminhelpannouncement
6 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.
  • V Offline
    V Offline
    vipin_nvk
    wrote on last edited by
    #1

    I have been trying to open particular registry key to know the version of Outlook currently installed on the PC. Here is the piece of code HKEY hKey; CString strKey = _T("Outlook.Application\\CurVer"); if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { // do something } else { DWORD dwError = GetLastError(); } The above piece of code fails to open the registry key and the GetLastError() returns error no. 122 which says "The data area passed to the system call is too small" I have administrative privilege on the PC, but this piece of code fails to open the key, what could be the reason, and how do I interpret the error returned? Thanx.

    J D 2 Replies Last reply
    0
    • V vipin_nvk

      I have been trying to open particular registry key to know the version of Outlook currently installed on the PC. Here is the piece of code HKEY hKey; CString strKey = _T("Outlook.Application\\CurVer"); if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { // do something } else { DWORD dwError = GetLastError(); } The above piece of code fails to open the registry key and the GetLastError() returns error no. 122 which says "The data area passed to the system call is too small" I have administrative privilege on the PC, but this piece of code fails to open the key, what could be the reason, and how do I interpret the error returned? Thanx.

      J Offline
      J Offline
      Jhony george
      wrote on last edited by
      #2

      vipin_nvk wrote:

      if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)

      Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"... I'm not sure,whther this will work ..but try...

      Born to win...!

      V R 2 Replies Last reply
      0
      • J Jhony george

        vipin_nvk wrote:

        if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)

        Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"... I'm not sure,whther this will work ..but try...

        Born to win...!

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

        This piece of code works fine at my place but fails with the above mentioned error at the client's place, so I wanted to know as to what could lead to the ERROR_INSUFFICIENT_BUFFER error so that it can be fixed and then sent across to the client. Do you think changing access to KEY_ALL_ACCESS will really work?

        J 1 Reply Last reply
        0
        • V vipin_nvk

          This piece of code works fine at my place but fails with the above mentioned error at the client's place, so I wanted to know as to what could lead to the ERROR_INSUFFICIENT_BUFFER error so that it can be fixed and then sent across to the client. Do you think changing access to KEY_ALL_ACCESS will really work?

          J Offline
          J Offline
          Jhony george
          wrote on last edited by
          #4

          vipin_nvk wrote:

          Do you think changing access to KEY_ALL_ACCESS will really work?

          No, the changing key access ...it wont solve ur problem.. It's something related to other problem... :(

          Born to win...!

          1 Reply Last reply
          0
          • J Jhony george

            vipin_nvk wrote:

            if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)

            Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"... I'm not sure,whther this will work ..but try...

            Born to win...!

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            Manivannan@congruent wrote:

            Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"...

            As a matter of fact, that is a very bad suggestion. You should open a registry key only with the privileges that you may actually need.

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

            1 Reply Last reply
            0
            • V vipin_nvk

              I have been trying to open particular registry key to know the version of Outlook currently installed on the PC. Here is the piece of code HKEY hKey; CString strKey = _T("Outlook.Application\\CurVer"); if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { // do something } else { DWORD dwError = GetLastError(); } The above piece of code fails to open the registry key and the GetLastError() returns error no. 122 which says "The data area passed to the system call is too small" I have administrative privilege on the PC, but this piece of code fails to open the key, what could be the reason, and how do I interpret the error returned? Thanx.

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

              Have you tried:

              HKEY hKey;

              LONG lResult = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("Outlook.Application\\CurVer"), 0, KEY_READ, &hKey);
              if (lResult == ERROR_SUCCESS)
              {
              // do something
              }
              else
              {
              LPVOID lpMsgBuf;

              FormatMessage(FORMAT\_MESSAGE\_ALLOCATE\_BUFFER | FORMAT\_MESSAGE\_FROM\_SYSTEM,
                            NULL,
                            lResult,
                            MAKELANGID(LANG\_NEUTRAL, SUBLANG\_DEFAULT),
                            (LPTSTR) &lpMsgBuf,
                            0,
                            NULL);
              ...
              LocalFree(lpMsgBuf);
              

              }

              "Love people and use things, not love things and use people." - Unknown

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              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