#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_SUPPORT_PLATFORM_WINDOWSREGISTRYAPI_H #define NUCLEX_SUPPORT_PLATFORM_WINDOWSREGISTRYAPI_H #include "Nuclex/Support/Config.h" #if defined(NUCLEX_SUPPORT_WINDOWS) #include "WindowsApi.h" #include // for std::string #include // for std::vector namespace Nuclex { namespace Support { namespace Platform { // ------------------------------------------------------------------------------------------- // /// Wraps the API used to interface with the registry on Windows systems class WindowsRegistryApi { /// Returns the registry hive matching its string name /// Name of the registry hive whose key will be returned /// The registry hive with the specified hive name /// /// This supports both the short form (HKCU/, HKLM/) and the long form /// (HKEY_CURRENT_USER/, HKEY_LOCAL_MACHINE/) for specifying the hive. /// public: static ::HKEY GetHiveFromString( const std::string &hiveName, std::string::size_type hiveNameLength ); /// /// Builds a list of the names of all registry keys directly below the key with /// the specified handle /// /// Handle of the key whose direct children will be queried /// A list containing the names of all child keys public: static std::vector GetAllSubKeyNames( ::HKEY keyHandle ); /// /// Builds a list of the names of all value directly below the key with /// the specified handle /// /// Handle of the key whose values will be queried /// A list containing the names of all value below the key public: static std::vector GetAllValueNames( ::HKEY keyHandle ); /// Opens a subkey below the specified parent registry key /// Handle of the parent registry key /// Name of the subkey that will be opened /// Whether the key will be opened with write permissions /// /// The handle of the opened registry subkey or a null pointer if the key doesn't exist /// public: static ::HKEY OpenExistingSubKey( ::HKEY parentKeyHandle, const std::string &subKeyName, bool writable = true ); /// Opens or creates a subkey below the specified parent registry key /// Handle of the parent registry key /// Name of the subkey that will be opened or created /// The handle of the opened or created registry subkey public: static ::HKEY OpenOrCreateSubKey( ::HKEY parentKeyHandle, const std::string &subKeyName ); /// Deletes the specified registry and all subkeys and values in it /// /// Handle of the key below which the key that will be deleted is located /// /// /// Name and or path of a subkey that will be deleted (if a path is specified, /// it's the bottommost key in the path that will be deleted) /// /// True if the key existed and was deleted, false if it didn't exist public: static bool DeleteTree(::HKEY parentKeyHandle, const std::string &subKeyName); }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Platform #endif // defined(NUCLEX_SUPPORT_WINDOWS) #endif // NUCLEX_SUPPORT_PLATFORM_WINDOWSREGISTRYAPI_H