Hello :)
I'm writing a class library that provides convenient object-oriented frontends to the C API that is the Windows Registry. I'm curious, however, what the best course of action is for handling HREG
s, for instances where my key
class is copied.
I can either
- Allocate a heap integer and use it as a reference count. Call RegCloseKey() on the handle and deallocate the integer when the refrence count equals zero.
- Use the builtin functionality of handles, and rather than maintaining a reference count, call
DuplicateHandle()
on the HREG when the registry key object is copied. Then always call RegCloseKey in destructors.
The DuplicateHandle()
design is much simpler, but I'm concerned if designing things that way is going to severely hamper performance of the application. Because my application recurses through hundreds of thousands of keys, speed of copying this object is a sensitive issue.
What are the inherent overheads of the DuplicateHandle()
function?