本文介绍了删除注册表项值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MSDN中,它说在调用更改枚举的注册表项的函数时不应使用RegEnumValue。
In MSDN it says that RegEnumValue should not be used when calling function that change the registry keys being enumerated.
那么这是否也适用于删除注册表项值?
So does this also apply to deleting registry key values?
就像下面的代码一样:
if (RegOpenKeyEx(m_hkey,m_path.c_str(),0,KEY_ALL_ACCESS,&key) == ERROR_SUCCESS) { bool error=false; idx=0; while (RegEnumValue(key,idx,name,&namesize,NULL,NULL,NULL,NULL) == ERROR_SUCCESS && !error) { error=(RegDeleteValue(key,name)!=ERROR_SUCCESS); idx++; } RegCloseKey(key); }推荐答案
您的代码不起作用。当您删除索引0时,下一项将变为索引0,并且您不会将其删除。
Your code does not work. When you delete index 0, the next item becomes index 0, and you do not delete that.
因此,它适用于删除键值。
So yes, it applies to deleting key values.
更多推荐
删除注册表项值
发布评论