diff --git a/sdk/lib/atl/atlbase.h b/sdk/lib/atl/atlbase.h index fa3cf72cd8a..502d7b1ad44 100644 --- a/sdk/lib/atl/atlbase.h +++ b/sdk/lib/atl/atlbase.h @@ -1043,6 +1043,7 @@ public: ~CRegKey() throw() { + Close(); } void Attach(HKEY hKey) throw() @@ -1359,7 +1360,11 @@ public: CRegKey& operator=(CRegKey& key) throw() { - Attach(key.Detach()); + if (m_hKey != key.m_hKey) + { + Close(); + Attach(key.Detach()); + } return *this; }