处理RegistryKey还会关闭吗?

正如标题所说。

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

我查看了所有可以找到的文档,并且在任何地方都没有提及。

它将调用Close()Dispose()方法,这意味着它将被“ disposed ”,而Dispose()其他方式将是Close() key 。 系统注册表项永远不会closed 。 只有正在closed keysHKEY_PERFORMANCE_DATA

Close方法的.NET源代码:

 /** * Closes this key, flushes it to disk if the contents have been modified. */ public void Close() { Dispose(true); } 

.NET源代码行220

Dispose方法的.NET源代码:

 [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