首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >处理RegistryKey也会关闭它吗?

处理RegistryKey也会关闭它吗?
EN

Stack Overflow用户
提问于 2016-05-05 19:52:13
回答 1查看 3K关注 0票数 9

就像标题上说的。

另外,反过来,关闭一个RegistryKey会处理它吗?

在我能找到的所有文档中,我都看过了,而且任何地方都没有提到这一点。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-05 20:00:38

它将在Close()中调用Close()方法,这意味着YES将是"disposed“,而Dispose()则是Close() key。系统注册表项从来都不是closed。只有keys才是closed - HKEY_PERFORMANCE_DATA

用于.NET方法的Close源:

代码语言:javascript
复制
/**
 * Closes this key, flushes it to disk if the contents have been modified.
 */
public void Close() {
    Dispose(true);
}

.NET源行220

用于.NET方法的Dispose源:

代码语言:javascript
复制
[System.Security.SecuritySafeCritical]  // auto-generated
private void Dispose(bool disposing) {
      if (hkey != null) {
           if (!IsSystemKey()) {
              try {
                  hkey.Dispose();
                }
                catch (IOException){
                    // we don't really care if the handle is invalid at this point
                }
                finally
                {
                    hkey = null;
                }
            }
            else if (disposing && IsPerfDataKey()) {
            SafeRegistryHandle.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA);
            }  
      }
}

.NET源行227

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37059120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档