Ejemplo n.º 1
0
        /// <summary>
        ///     Deletes a subkey of this key. The subkey must not contain any subkeys of its own, to delete recursively - see
        ///     <see
        ///         cref="DeleteSubKeyTree" />
        ///     .
        /// </summary>
        /// <param name="name">The name of the subkey to delete</param>
        public void DeleteSubKey(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            Win32Result result = OffregNative.DeleteKey(_intPtr, name);

            if (result != Win32Result.ERROR_SUCCESS)
            {
                throw new Win32Exception((int)result);
            }

            RefreshMetadata();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Deletes this key, further operations will be invalid (except calls to <see cref="Close" />).
        /// </summary>
        public void Delete()
        {
            if (_parent == null)
            {
                throw new InvalidOperationException("Cannot delete the root key");
            }

            Win32Result result = OffregNative.DeleteKey(_intPtr, null);

            if (result != Win32Result.ERROR_SUCCESS)
            {
                throw new Win32Exception((int)result);
            }

            // Refresh parent
            _parent.RefreshMetadata();
        }