Tom Spear wrote:
At the risk of looking like an idiot, I'll take a stab at this.. If you RegCloseKey on env, and it is not initialized, then RegCloseKey will generate ERROR_INVALID_HANDLE, so I personally think that something like the first approach would be the better one to go with. env should only be initialized (according to what I have seen) if RegOpenKeyExW returns ERROR_SUCCESS. But I haven't seen every case, so there may be something that causes it to be initialized when the return is not ERROR_SUCCESS.
Thanks, Tom. I think I might submit a patch to fix the violation that Coverity flags, which is prior to the RegOpenKeyW() call, and just insert a FIXME: comment where the return value of RegOpenKeyW() is tested, without changing the existing functionality.