就像标题上说的。
另外,反过来,关闭一个RegistryKey会处理它吗?
在我能找到的所有文档中,我都看过了,而且任何地方都没有提到这一点。
发布于 2016-05-05 20:00:38
它将在Close()中调用Close()方法,这意味着YES将是"disposed“,而Dispose()则是Close() key。系统注册表项从来都不是closed。只有keys才是closed - HKEY_PERFORMANCE_DATA。
用于.NET方法的Close源:
/**
* Closes this key, flushes it to disk if the contents have been modified.
*/
public void Close() {
Dispose(true);
}.NET源行220
用于.NET方法的Dispose源:
[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
https://stackoverflow.com/questions/37059120
复制相似问题