+ -
当前位置:首页 → 问答吧 → 关于Win32API操作注册表问题

关于Win32API操作注册表问题

时间:2011-12-26

来源:互联网

最近看别人操作注册表的源代码 感觉有点疑惑 有的代码是直接操作RegCreateKey()函数来修改注册表 而有的代码是先调用RegOpenKey()获取注册表对象 然后调用RegCreateKey()来操作 请问这两种方式使用起来有区别吗??

作者: fuly_ABC   发布时间: 2011-12-26

二个函数的区别可以参见MSDN:
RegOpenKey:
  Opens the specified registry key,RegOpenKey does not create the specified key if the key does not exist in the database。

RegCreateKey:
  Creates the specified registry key,If the key already exists in the registry, the function opens it。

简单的说RegOpenKey用于打开已有键值,RegCreateKey用于打开已有键值或者创建并打开新键值。

作者: fight_in_dl   发布时间: 2011-12-26