The information in this article applies to:
SYMPTOMSA Win32-based application runs under Windows 95 but does not run correctly under Windows NT. Or a Windows-based application runs under Windows 95 but leaks registry handles under Windows NT. CAUSE
Windows NT RegOpenKeyEx always returns a unique handle. Windows 95
RegOpenKeyEx returns the same handle each time the same key is opened.
Windows 95 keeps a reference count, incrementing it each time the key
is opened with RegOpenKeyEx and decrementing it each time the key is
closed with RegCloseKey. The key remains open as long as the reference
count is greater than zero.
This code is incorrect, but it works under Windows 95 because OldKey and NewKey refer to the same key. However, the code fails under Windows NT, because NewKey is not valid after it is closed. In a related issue, RegOpenKey with a NULL subkey string on Windows NT will return the same handle that was passed in. Under Windows 95, the reference count is incremented.
This code works under Windows 95 because NewKey is still valid after closing OldKey, but the code fails under Windows NT. Code that is correct for Windows NT (don't close the handle until both OldKey and NewKey are no longer needed) leaks registry handles under Windows 95. RESOLUTIONYou should use RegOpenKeyEx and make sure that there is a corresponding close call for each open call. This will ensure that you do not use any handle that has been closed. STATUSThis behavior is by design. Additional query words: 4.00 Windows win95fest
Keywords : kbKernBase kbRegistry kbGrpKernBase |
Last Reviewed: March 7, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |