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. Using the CRegistry class

Using the CRegistry class

Scheduled Pinned Locked Moved C / C++ / MFC
c++windows-admindebugginghelpquestion
5 Posts 3 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
    Larry Mills Sr
    wrote on last edited by
    #1

    I used the class to obtain values that an installer package saved to the registry. I can see the values in Regedit. but when the CRegistry class (readline()) never reads them! I really need a solution to this: here's my code: // App command to run the dialog void CShopApp::FindRegData() { CRegistry Reg(); CRegData m_cRegData;// class of 5 CStrings m_cRegData.CleanUp(); //CRegistry Reg; CString csSubRoot = "SOFTWARE\\Mills Software Solutions Inc\\Shop"; m_cRegData.m_csRootMainKey = "HKEY_LOCAL_MACHINE"; m_cRegData.m_csSubKey = csSubRoot; Reg.SetRootKey(HKEY_LOCAL_MACHINE); if (Reg.SetKey(csSubRoot, FALSE))// jumps out here { m_cRegData.m_csCompany = Reg.ReadString("Company", "");// all CStrings in class m_cRegData are "bad pointer" errors m_cRegData.m_csUser = Reg.ReadString("Name", ""); m_cRegData.m_csSerialCode = Reg.ReadString("Serial", ""); m_cRegData.m_csRegCode = Reg.ReadString("RegCode", ""); //Reg } else { TRACE("Failed to open key\n"); } m_csSaveData = InsertDelimiterReg(m_cRegData);// all CStrings Bad pointer FileSaveRegData(); } Can someone please explain why this is happening? I used REGEDIT and found that the key and values are there! I just can't get CRegistry to retrieve them. Help!

    A C++ programming language novice, but striving to learn

    D J 2 Replies Last reply
    0
    • L Larry Mills Sr

      I used the class to obtain values that an installer package saved to the registry. I can see the values in Regedit. but when the CRegistry class (readline()) never reads them! I really need a solution to this: here's my code: // App command to run the dialog void CShopApp::FindRegData() { CRegistry Reg(); CRegData m_cRegData;// class of 5 CStrings m_cRegData.CleanUp(); //CRegistry Reg; CString csSubRoot = "SOFTWARE\\Mills Software Solutions Inc\\Shop"; m_cRegData.m_csRootMainKey = "HKEY_LOCAL_MACHINE"; m_cRegData.m_csSubKey = csSubRoot; Reg.SetRootKey(HKEY_LOCAL_MACHINE); if (Reg.SetKey(csSubRoot, FALSE))// jumps out here { m_cRegData.m_csCompany = Reg.ReadString("Company", "");// all CStrings in class m_cRegData are "bad pointer" errors m_cRegData.m_csUser = Reg.ReadString("Name", ""); m_cRegData.m_csSerialCode = Reg.ReadString("Serial", ""); m_cRegData.m_csRegCode = Reg.ReadString("RegCode", ""); //Reg } else { TRACE("Failed to open key\n"); } m_csSaveData = InsertDelimiterReg(m_cRegData);// all CStrings Bad pointer FileSaveRegData(); } Can someone please explain why this is happening? I used REGEDIT and found that the key and values are there! I just can't get CRegistry to retrieve them. Help!

      A C++ programming language novice, but striving to learn

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

      Larry Mills Sr wrote:

      I used the class...

      This one?

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "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

      L 1 Reply Last reply
      0
      • D David Crow

        Larry Mills Sr wrote:

        I used the class...

        This one?

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "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

        L Offline
        L Offline
        Larry Mills Sr
        wrote on last edited by
        #3

        I found the culprit. ERROR_ACCESS_DENIED (Error # 5). How do I tell my program to "Run As Administrator" PROGRAMMATICALLY, without the User having to do anything IN MFC!

        A C++ programming language novice, but striving to learn

        D 1 Reply Last reply
        0
        • L Larry Mills Sr

          I found the culprit. ERROR_ACCESS_DENIED (Error # 5). How do I tell my program to "Run As Administrator" PROGRAMMATICALLY, without the User having to do anything IN MFC!

          A C++ programming language novice, but striving to learn

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

          Larry Mills Sr wrote:

          How do I tell my program to "Run As Administrator" PROGRAMMATICALLY, without the User having to do anything...

          Have you looked at AdjustTokenPrivileges()?

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "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

          1 Reply Last reply
          0
          • L Larry Mills Sr

            I used the class to obtain values that an installer package saved to the registry. I can see the values in Regedit. but when the CRegistry class (readline()) never reads them! I really need a solution to this: here's my code: // App command to run the dialog void CShopApp::FindRegData() { CRegistry Reg(); CRegData m_cRegData;// class of 5 CStrings m_cRegData.CleanUp(); //CRegistry Reg; CString csSubRoot = "SOFTWARE\\Mills Software Solutions Inc\\Shop"; m_cRegData.m_csRootMainKey = "HKEY_LOCAL_MACHINE"; m_cRegData.m_csSubKey = csSubRoot; Reg.SetRootKey(HKEY_LOCAL_MACHINE); if (Reg.SetKey(csSubRoot, FALSE))// jumps out here { m_cRegData.m_csCompany = Reg.ReadString("Company", "");// all CStrings in class m_cRegData are "bad pointer" errors m_cRegData.m_csUser = Reg.ReadString("Name", ""); m_cRegData.m_csSerialCode = Reg.ReadString("Serial", ""); m_cRegData.m_csRegCode = Reg.ReadString("RegCode", ""); //Reg } else { TRACE("Failed to open key\n"); } m_csSaveData = InsertDelimiterReg(m_cRegData);// all CStrings Bad pointer FileSaveRegData(); } Can someone please explain why this is happening? I used REGEDIT and found that the key and values are there! I just can't get CRegistry to retrieve them. Help!

            A C++ programming language novice, but striving to learn

            J Offline
            J Offline
            Joschwenk666
            wrote on last edited by
            #5

            Old Thread, but I had the same problem with CRegistry class in Windows 7. But my compiled Program didn`t have the problem, so I just activated the "Run as Administrator" option for my Visual Studio, and CRegistry could read the Registry Keys...

            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