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