开发者

Deleting registry key values

开发者 https://www.devze.com 2023-01-04 18:52 出处:网络
In MSDN it says that RegEnumValue should not be used when calling function that change the registry keys being enumerated.

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

精彩评论

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