Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been strugling eleminate error while updating registry.

I have a legacy VC++(VS 6.0) code working fine in windows XP.But the same code is failing at UpdateRegistry("AfxOleRegisterServerClass") function call in windows 7.Error message as,

"failed to update system registry please try using regedit"

Could please suggest me should I go with RegCreateKeyEx(), RegSetValueEx()
or is there any solution for the error message.
Posted

Probably your application has not the required privileges to do that (you may try to 'run as administrator' it, to verify). You have to elevate application privileges (have a look at the following CodeProject's article: "Vista UAC: The Definitive Guide"[^]).
 
Share this answer
 
Comments
deepa_ubdt 25-Jan-12 7:41am    
Application work when we try Run as administrator...

I could not find out the solution for Visual studio 6.0 to elevate application privileges.


Could you please help me whethere I should do Enable/Disable Privileges.
If so could you please show the step to follow
Added access priviledge with KEY_WRITE and RegCloseKey(hTestKey) after UpdateRegistryAll().

Example:
HKEY hTestKey = NULL;
LONG lResult = ::RegCreateKeyEx(HKEY_CLASSES_ROOT,
"MFCOServ.Document", 0, "",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL,
&hTestKey, NULL);
if ((ERROR_SUCCESS == lResult) && (hTestKey != NULL))
{
// It's ok to call UpdateRegistry
}

Information collected from,
http://support.microsoft.com/kb/254957
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900