Exemplo n.º 1
0
        public override void Close()
        {
            if (_intPtr != IntPtr.Zero && _ownsPointer)
            {
                Win32Result res = OffregNative.CloseKey(_intPtr);

                if (res != Win32Result.ERROR_SUCCESS)
                {
                    throw new Win32Exception((int)res);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Detect if a subkey exists in this key.
        /// </summary>
        /// <param name="name">The subkey to find</param>
        /// <returns>True if it exists, false otherwise.</returns>
        public bool SubkeyExist(string name)
        {
            IntPtr intPtr = IntPtr.Zero;

            try
            {
                Win32Result result = OffregNative.OpenKey(_intPtr, name, out intPtr);

                return(result == Win32Result.ERROR_SUCCESS);
            }
            finally
            {
                // Close up shop
                if (intPtr != IntPtr.Zero)
                {
                    OffregNative.CloseKey(intPtr);
                }
            }
        }