internal override ConfigurationProvider OpenKey(string subKey)
        {
            SafeHKey hSubKey;
            int      disposition;
            int      ret = SafeNativeMethods.ClusterRegCreateKey(hKey,
                                                                 subKey,
                                                                 SafeNativeMethods.REG_OPTION_NON_VOLATILE,
                                                                 RegistryRights.FullControl,
                                                                 IntPtr.Zero,
                                                                 out hSubKey,
                                                                 out disposition);

            if (ret != SafeNativeMethods.ERROR_SUCCESS)
            {
                throw new WsatAdminException(WsatAdminErrorCode.REGISTRY_ACCESS, SR.GetString(SR.CannotOpenClusterRegistry, ret));
            }

            return(new ClusterRegistryConfigurationProvider(hSubKey, registryKey + subKey));
        }
        internal ClusterRegistryConfigurationProvider(SafeHResource hResource, string key)
        {
            SafeHKey rootKey = SafeNativeMethods.GetClusterResourceKey(hResource,
                                                                       RegistryRights.ReadKey |
                                                                       RegistryRights.EnumerateSubKeys |
                                                                       RegistryRights.QueryValues);

            if (rootKey.IsInvalid)
            {
                int lastError = Marshal.GetLastWin32Error();
                throw new WsatAdminException(WsatAdminErrorCode.REGISTRY_ACCESS, SR.GetString(SR.CannotOpenClusterRegistry, lastError));
            }

            if (string.IsNullOrEmpty(key))
            {
                hKey = rootKey;
            }
            else
            {
                using (rootKey)
                {
                    int disposition;
                    int ret = SafeNativeMethods.ClusterRegCreateKey(rootKey,
                                                                    key,
                                                                    SafeNativeMethods.REG_OPTION_NON_VOLATILE,
                                                                    RegistryRights.FullControl,
                                                                    IntPtr.Zero,
                                                                    out this.hKey,
                                                                    out disposition);
                    if (ret != SafeNativeMethods.ERROR_SUCCESS)
                    {
                        throw new WsatAdminException(WsatAdminErrorCode.REGISTRY_ACCESS, SR.GetString(SR.CannotOpenClusterRegistry, ret));
                    }
                }
            }

            registryExceptionHelper = new RegistryExceptionHelper(key);
            this.registryKey        = key;
            RegistryExceptionHelper.EnsureEndsWithSlash(ref this.registryKey);
        }