问题描述
我正在写一个用于在注册表中设置键/值的函数。我有一个问题:
我调用RegOpenKeyEx()并返回ERROR_SUCCESS和
然后调用RegSetValueEx设置键/值,但返回ERROR_ACCESS_DENIED
RegOpenKeyEx(HKEY)hive,branch.c_str(),NULL,ACCESS_SYSTEM_SECURITY ; hkey_result);
RegSetValueEx(hkey_result,name.c_str(),0,REG_SZ,(BYTE *)value.c_str(),
((DWORD)wcslen(value.c_str )* sizeof(wchar_t));
我的功能运行在Windows 7上,我的程序也通过嵌入清单vs2010 IDE设置UAC >
我想要设置键/值的分支:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html \UserChoice
我认识到当我在UserChoice上选择了权限菜单(使用注册表编辑器(Regedt32.exe)),它有specical permisions在拒绝列上选中的值项
hi all!
将 ACCESS_SYSTEM_SECURITY
更改为 KEY_SET_VALUE
。
I am writing a function for setting key/value on registry. I have a problem:
I call RegOpenKeyEx() and it returns ERROR_SUCCESS and
I then call RegSetValueEx to set key/value but it returns ERROR_ACCESS_DENIED
RegOpenKeyEx((HKEY)hive, branch.c_str(), NULL, ACCESS_SYSTEM_SECURITY, &hkey_result);
RegSetValueEx(hkey_result, name.c_str(), 0, REG_SZ, (BYTE*)value.c_str(),
((DWORD)wcslen(value.c_str()) + 1)* sizeof(wchar_t));
my function runs on Windows 7 and my program also sets UAC by embeding manifest with vs2010 IDE
The branch which i want to set key/value:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice
i recognize that when i selected Permissions menu(use the Registry Editor (Regedt32.exe)) on UserChoice and it has "specical permisions" field with "Set Value" item checked on Deny column
hi all! can you help me?
Change ACCESS_SYSTEM_SECURITY
to KEY_SET_VALUE
.
这篇关于RegOpenKeyEx返回ERROR_SUCCESS,但RegSetValueEx allways返回ERROR_ACCESS_DENIED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!