如何允许在Windows 7中设置系统注册表 [英] How to allow to set system registry in windows 7
问题描述
VC ++我在更新注册表时一直在努力消除错误.
我有一个旧的VC ++(VS 6.0)代码在Windows XP中可以正常工作.但是在Windows 7中,UpdateRegistry("AfxOleRegisterServerClass")函数调用时,相同的代码失败了,错误消息为,
无法更新系统注册表,请尝试使用regedit"
能否建议我应该使用RegCreateKeyEx(),RegSetValueEx()
或对于错误消息有任何解决方案.
当我们选择以管理员身份运行..."时,应用程序工作正常.我找不到Visual Studio 6.0提升应用程序特权的解决方案.
请帮助我是否应该启用/禁用特权.如果是这样,请显示要遵循的步骤
VC++ 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.
Application work fine when we select Run as administrator... I could not find out the solution for Visual studio 6.0 to elevate application privileges.
Please help me whethere I should do Enable/Disable Privileges. If so, Please show the step to follow
推荐答案
在我链接的文章中(作为对 ^ ],非常类似的问题),对步骤进行了说明.甚至还有使用COM
进行此操作的示例代码.
In the article I linked (as answer to your previous[^], very similar question) the steps are explained. There''s even sample code for doing that with COM
.
在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中设置系统注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!