关于WinCE调用RegDeleteKey不能删除注册表项的问题
来源:互联网 发布:淘宝购物车需求分析 编辑:程序博客网 时间:2024/05/21 06:51
在写一个WinCE注册表操作的时候,调用RegDeleteKey函数却不能删除注册表项,始终返回5的错误(ACCESS DENY)。查了一下,有的说是什么权限的问题,操作的时候都是先打开注册表,如果打开成功,即调用RegDeleteKey删除此键,其实这都是不对的,经过反复查看其文档介绍,终于在一个不起眼的句子中找到了答案。下面先介绍一个此函数,直接贴原文。
RegDeleteKey (Windows CE 5.0)
This function recursively deletes all subkeys of a named subkey of a specified registry key.
A remote application interface (RAPI) version of this function exists, and it is called CeRegDeleteKey (RAPI).
LONG RegDeleteKey( HKEY hKey, LPCWSTR lpSubKey );
Parameters
- hKey
- [in] Handle to a currently open key or one of the following predefined reserved handle values:
- HKEY_CLASSES_ROOT
- HKEY_CURRENT_USER
- HKEY_LOCAL_MACHINE
- HKEY_USERS
The key specified by the lpSubKey parameter must be a subkey of the key identified by hKey.
The access rights of this key do not affect the delete operation.
- lpSubKey
- [in] Pointer to a null-terminated string specifying the name of the key to delete. This parameter cannot be NULL.
Return Values
ERROR_SUCCESS indicates success. A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, call FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you callFormatMessage it could fail.
Remarks
If the function succeeds, RegDeleteKey removes the specified key from the registry. The entire key, including all of its values, is removed. An application cannot call RegDeleteKey for a key that an application currently has open.
To open the key, use the RegCreateKeyEx or RegOpenKeyEx function.
Handle to a currently open key or one of the following predefined reserved handle values
An application cannot call RegDeleteKey for a key that an application currently has open.
就是说,键的访问权限不影响RegDeleteKey的删除操作,对于预先定义好的键值,不能在一个已经打开的键上调用RegDeleteKey,否则会报5的错误,即无需打开再删除,而是直接调用此函数删除键值。如下为例子:
要删除的键值为:
HKEY_LOCAL_MACHINE/Services/FinServ
代码为:
HKEY RootKey = HKEY_LOCAL_MACHINE;
CString strSubKey = _T("\\Services\\FinServ");
long nRet = 0;
nRet = RegDeleteKey(RootKey,strSubKey);
if(nRet== ERROR_SUCCESS)
{
//删除成功
}
- 关于WinCE调用RegDeleteKey不能删除注册表项的问题
- 关于RegDeleteKey无法删除注册表项
- Wince关于Flash的永久保存注册表
- 关于wince注册表
- 关于wince注册表
- 关于wince注册表
- 关于wince注册表
- 关于wince注册表
- 关于Firefox3 不能调用DWR的问题
- 注册表项目不能删除的解决方案
- 从注册表删除桌面上不能删除的图标
- 关于注册表的一些问题
- 关于wince SD 卡HIVE注册表的问题解决方法探讨
- SSH中关于级联删除不能实现的一些问题
- 关于WinCE的unicode问题
- 关于WinCE的unicode问题
- wince 不能生成eboot的问题
- 关于vs2005远程工具不能连接wince设备进行调试的问题
- 大牛一片片 少年你啥也不是
- Ubuntu 搭建个人博客WordPress环境
- 如何让wireshark解码任意层的数据
- JSTL标签之核心标签库
- 11个iOS面试问题
- 关于WinCE调用RegDeleteKey不能删除注册表项的问题
- Session服务器配置指南与使用经验
- 随便玩了玩unordered_map
- error和exception的区别,RuntimeException和非RuntimeException的区别
- PHP的RPC框架:Yar
- Java编程优化之旅(一)一般化方法
- 一个菜鸟初学树莓派(1)
- 菜鸟一样要长大
- Android多线程Handler的使用,基于源代码理解。