On MSDN, the description of the failed return value of the funciton ReCloseKey is below, in which does not state whether the key will be leaked.
A nonzero error code defined in Winerror.h indicates failure. To get a generic description of the error, callFormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag set. The message resource is optional; therefore, if you callFormatMessage it could fail.
Will the register key be leakage if the function ReCloseKey fails? If yes, what is the reason?
I use Visual Studio 2005 to develop my application, which is running on Windows Server 2008 R2 standard. Recently we were reported a hanle leak issue, it was identified as a registry key leakage. Our program looks good, we open a registry key, then write some value to it, then close it. The code path has been tested on my lab, no issue was find.
Thanks,
Jason