开发者

Deleting registry key values

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,K开发者_Go百科EY_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);
 }


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜