May 19, 2006
I was wondering why 'basic_reg_key_sequence' does not have a member function to access the key's handle.  I would have wanted such a member function to determine if the key was opened successfully. Or is there some other way to check for a failure to open the key.

Thanks

Allan McLellan


May 19, 2006
Hi Allan

>I was wondering why 'basic_reg_key_sequence' does not have a member function to
> access the key's handle.  I would have wanted such a member function to
> determine if the key was opened successfully. Or is there some other way
> to
> check for a failure to open the key.

When compiling with exception support, failure to open a key is indicated by the throwing of an instance of registry_exception. But you're correct that there is no unambiguous way to determine whether key opening is successful when compiling without exception support: a non-0 return from empty() might as well indicate a successfully opened key with no elements.

So, I've just amended it to add the get_key_handle() and get() methods.

However, in doing so, I've realised that in some of the cases where an exception is thrown the associated error code (available via windows_exception::get_error_code()) will be 0, since they are assigned from GetLastError() and the registry functions don't (always) affect the thread error code. Hence, I should really do some further amendments to ensure that full information is available in all cases of thrown exception.

I'm way behind in releasing the next 1.9 beta, but I'll try and make all these registry changes in the next couple of days and released a next beta.

In the meanwhile I'm including the updated winstl/registry/reg_key_sequence.hpp. (This assumes you've downloaded and are using 1.9 beta 5, of course.) Please let me know how you go.

Cheers

Matthew