解决方法
它将调用Close()中的Dispose()方法,这意味着它将被“处理”,而Dispose()的其他方式将是Close()键.系统注册表项永远不会关闭.只有正在关闭的键 – HKEY_PERFORMANCE_DATA.
/** * Closes this key,flushes it to disk if the contents have been modified. */ public void Close() { Dispose(true); }
[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); } } }