Deleting registry key values

对着背影说爱祢 提交于 2019-12-02 20:13:54

问题


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?

Like this code does:

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);
 }

回答1:


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.



来源:https://stackoverflow.com/questions/3131055/deleting-registry-key-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!