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. RegOpenKey error i cant figure out

RegOpenKey error i cant figure out

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 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.
  • L Offline
    L Offline
    locoone
    wrote on last edited by
    #1

    HKEY hKey;
    CString path;

    hKey = HKEY\_LOCAL\_MACHINE;
    err = ERROR\_SUCCESS;
    
    m\_list.InsertItem(0, "HKEY\_LOCAL\_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B");
    path = "SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B";
    
    err = RegOpenKeyEx(hKey, path, NULL, KEY\_ALL\_ACCESS, &hKey);
    if (err == ERROR\_SUCCESS)
    {
    	m\_list.SetItemText(0, 1, "Found");
    	ErrorExit("RegOpenKey0");
    }
    else
    {
    	m\_list.SetItemText(0, 1, "Not Found"); <--- this is the one i keep getting
    	ErrorExit("RegOpenKey1");
    }
    RegCloseKey(hKey);
    

    that is the code and it keeps returning error 2 system cant find file but i know the path is good i copied the key from regedit i am on vista 64 bit if it makes a differance ill take any help i can get

    D M R 3 Replies Last reply
    0
    • L locoone

      HKEY hKey;
      CString path;

      hKey = HKEY\_LOCAL\_MACHINE;
      err = ERROR\_SUCCESS;
      
      m\_list.InsertItem(0, "HKEY\_LOCAL\_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B");
      path = "SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B";
      
      err = RegOpenKeyEx(hKey, path, NULL, KEY\_ALL\_ACCESS, &hKey);
      if (err == ERROR\_SUCCESS)
      {
      	m\_list.SetItemText(0, 1, "Found");
      	ErrorExit("RegOpenKey0");
      }
      else
      {
      	m\_list.SetItemText(0, 1, "Not Found"); <--- this is the one i keep getting
      	ErrorExit("RegOpenKey1");
      }
      RegCloseKey(hKey);
      

      that is the code and it keeps returning error 2 system cant find file but i know the path is good i copied the key from regedit i am on vista 64 bit if it makes a differance ill take any help i can get

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

      locoone wrote:

      that is the code and it keeps returning error 2 system cant find file...

      If the function fails, the return value is a nonzero error code defined in Winerror.h.

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

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      L 1 Reply Last reply
      0
      • D David Crow

        locoone wrote:

        that is the code and it keeps returning error 2 system cant find file...

        If the function fails, the return value is a nonzero error code defined in Winerror.h.

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

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        L Offline
        L Offline
        locoone
        wrote on last edited by
        #3

        that part i know the part i cant figure out is why it cant find it i was in regedit and used the copy key name to get the key path so i know its right out of 24 keys it finds 12 and cant find 12

        modified on Saturday, August 9, 2008 11:28 PM

        1 Reply Last reply
        0
        • L locoone

          HKEY hKey;
          CString path;

          hKey = HKEY\_LOCAL\_MACHINE;
          err = ERROR\_SUCCESS;
          
          m\_list.InsertItem(0, "HKEY\_LOCAL\_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B");
          path = "SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B";
          
          err = RegOpenKeyEx(hKey, path, NULL, KEY\_ALL\_ACCESS, &hKey);
          if (err == ERROR\_SUCCESS)
          {
          	m\_list.SetItemText(0, 1, "Found");
          	ErrorExit("RegOpenKey0");
          }
          else
          {
          	m\_list.SetItemText(0, 1, "Not Found"); <--- this is the one i keep getting
          	ErrorExit("RegOpenKey1");
          }
          RegCloseKey(hKey);
          

          that is the code and it keeps returning error 2 system cant find file but i know the path is good i copied the key from regedit i am on vista 64 bit if it makes a differance ill take any help i can get

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Do you get different results if you use KEY_QUERY_VALUE instead of KEY_ALL_ACCESS? Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          • L locoone

            HKEY hKey;
            CString path;

            hKey = HKEY\_LOCAL\_MACHINE;
            err = ERROR\_SUCCESS;
            
            m\_list.InsertItem(0, "HKEY\_LOCAL\_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B");
            path = "SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Installer\\\\UserData\\\\S-1-5-18\\\\Products\\\\109C30587D582624882DD8B8A2B7808B";
            
            err = RegOpenKeyEx(hKey, path, NULL, KEY\_ALL\_ACCESS, &hKey);
            if (err == ERROR\_SUCCESS)
            {
            	m\_list.SetItemText(0, 1, "Found");
            	ErrorExit("RegOpenKey0");
            }
            else
            {
            	m\_list.SetItemText(0, 1, "Not Found"); <--- this is the one i keep getting
            	ErrorExit("RegOpenKey1");
            }
            RegCloseKey(hKey);
            

            that is the code and it keeps returning error 2 system cant find file but i know the path is good i copied the key from regedit i am on vista 64 bit if it makes a differance ill take any help i can get

            R Offline
            R Offline
            Rob Manderson
            wrote on last edited by
            #5

            Unicode? If I recall correctly it's possible to have keys that regedit can't display correctly. Thus, if you copy and paste you're not copying the entire key. I'd write a quick and dirty iteration over the root key dumping the raw bytes in each key name to make sure you have the entire key.

            Rob Manderson My bloghttp://robmanderson.blogspot.com[^]

            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