Beispiel #1
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary> Get a sub key of this registry key and fail if it does
        /// not exist </summary>
        /// <param name="subKeyName"> The name of the sub key </param>
        /// <returns> The registry key to use, null if the sub key does not
        /// exist </returns>
        ///////////////////////////////////////////////////////////////////////
        public RegKey GetSubKey(string subKeyName)
        {
            // Attempt to open the sub key
            Microsoft.Win32.RegistryKey subKey = m_RegKey.OpenSubKey(subKeyName, true);
            if (subKey == null)
            {
                return(null);
            }

            // Create a new registry key
            RegKey retSubKey = new RegKey();

            retSubKey.m_RegKey = subKey;

            // Return the sub key object
            return(retSubKey);
        }
Beispiel #2
0
        ///////////////////////////////////////////////////////////////////////
        /// <summary> Get a sub key of this registry key and create it if it
        /// does no exist </summary>
        /// <param name="subKeyName"> The name of the sub key </param>
        /// <param name="createIfDoesntExist"> True if the sub key should be
        /// created if it doesn't exist, false if the subkey will not be
        /// created </param>
        /// <returns> The registry key to use, null if the sub key does not
        /// exist or couldn't be created </returns>
        ///////////////////////////////////////////////////////////////////////
        public RegKey CreateSubKey(string subKeyName)
        {
            // Attempt to get the registry key
            RegKey subKey = GetSubKey(subKeyName);

            // If we got the sub key
            if (subKey != null)
            {
                return(subKey);
            }

            // Attempt to create the sub key
            Microsoft.Win32.RegistryKey newSubKey = m_RegKey.CreateSubKey(subKeyName);
            if (newSubKey == null)
            {
                return(null);
            }

            // Create and return the new sub key object
            RegKey retSubKey = new RegKey();

            retSubKey.m_RegKey = newSubKey;
            return(retSubKey);
        }