Windows 7中updateRegistry中的错误 [英] Error in updateRegistry in Windows 7

查看:845
本文介绍了Windows 7中updateRegistry中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新注册表时,我一直在努力消除错误.

我有一个旧的VC ++(VS 6.0)代码在Windows XP中可以正常工作.但是在Windows 7中,UpdateRegistry("AfxOleRegisterServerClass")函数调用时,相同的代码失败了,错误消息为,

无法更新系统注册表,请尝试使用regedit"

能否建议我应该使用RegCreateKeyEx(),RegSetValueEx()
还是有针对该错误消息的解决方案.

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.

推荐答案

可能您的应用程序没有执行此操作所需的特权(您可以尝试以<<>管理员''进行验证).您必须提升应用程序特权(请查看以下CodeProject的文章:"Vista UAC:权威指南" [
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"[^]).


在UpdateRegistryAll()之后添加了具有KEY_WRITE和RegCloseKey(hTestKey)的访问权限.
示例:
HKEY hTestKey = NULL;
长lResult = :: RegCreateKeyEx(HKEY_CLASSES_ROOT,
"MFCOServ.Document",0,",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,NULL,
& hTestKey,NULL);
if(((ERROR_SUCCESS == lResult)&&(hTestKey!= NULL))
{
//可以调用UpdateRegistry
}

收集的信息,
http://support.microsoft.com/kb/254957
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


这篇关于Windows 7中updateRegistry中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆