Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Refactor RegistryHelper code and project structure
Browse files Browse the repository at this point in the history
- Renamed RegistryHelper.cpp to RegistryInterface.h
- Updated include paths in RegistryInterface.h
- Added error code handling in RegistryError class
- Updated project file paths and namespaces in .vcxproj files
  • Loading branch information
Arteiii committed Feb 16, 2024
1 parent 3446185 commit c59a9ba
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 101 deletions.
28 changes: 9 additions & 19 deletions RegistryHelper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34526.213
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegistryHelper", "RegistryHelper\RegistryHelper.vcxproj", "{7144564F-FE5B-4B24-A6A9-C83F18969BBB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3587BC45-E1D1-4FCE-9F36-D4BD660FB262}"
ProjectSection(SolutionItems) = preProject
.clang-format = .clang-format
Expand All @@ -15,7 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Example", "Example\Example.vcxproj", "{FD807556-B9F5-4D19-814A-FE0F51F514E1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{D4D6B041-259C-4200-9C05-A482841857DC}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegistryInterface", "RegistryInterface\RegistryInterface.vcxproj", "{40299226-5106-4793-A43D-9BBB17111B64}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -25,14 +23,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Debug|x64.ActiveCfg = Debug|x64
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Debug|x64.Build.0 = Debug|x64
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Debug|x86.ActiveCfg = Debug|Win32
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Debug|x86.Build.0 = Debug|Win32
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Release|x64.ActiveCfg = Release|x64
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Release|x64.Build.0 = Release|x64
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Release|x86.ActiveCfg = Release|Win32
{7144564F-FE5B-4B24-A6A9-C83F18969BBB}.Release|x86.Build.0 = Release|Win32
{FD807556-B9F5-4D19-814A-FE0F51F514E1}.Debug|x64.ActiveCfg = Debug|x64
{FD807556-B9F5-4D19-814A-FE0F51F514E1}.Debug|x64.Build.0 = Debug|x64
{FD807556-B9F5-4D19-814A-FE0F51F514E1}.Debug|x86.ActiveCfg = Debug|Win32
Expand All @@ -41,14 +31,14 @@ Global
{FD807556-B9F5-4D19-814A-FE0F51F514E1}.Release|x64.Build.0 = Release|x64
{FD807556-B9F5-4D19-814A-FE0F51F514E1}.Release|x86.ActiveCfg = Release|Win32
{FD807556-B9F5-4D19-814A-FE0F51F514E1}.Release|x86.Build.0 = Release|Win32
{D4D6B041-259C-4200-9C05-A482841857DC}.Debug|x64.ActiveCfg = Debug|x64
{D4D6B041-259C-4200-9C05-A482841857DC}.Debug|x64.Build.0 = Debug|x64
{D4D6B041-259C-4200-9C05-A482841857DC}.Debug|x86.ActiveCfg = Debug|Win32
{D4D6B041-259C-4200-9C05-A482841857DC}.Debug|x86.Build.0 = Debug|Win32
{D4D6B041-259C-4200-9C05-A482841857DC}.Release|x64.ActiveCfg = Release|x64
{D4D6B041-259C-4200-9C05-A482841857DC}.Release|x64.Build.0 = Release|x64
{D4D6B041-259C-4200-9C05-A482841857DC}.Release|x86.ActiveCfg = Release|Win32
{D4D6B041-259C-4200-9C05-A482841857DC}.Release|x86.Build.0 = Release|Win32
{40299226-5106-4793-A43D-9BBB17111B64}.Debug|x64.ActiveCfg = Debug|x64
{40299226-5106-4793-A43D-9BBB17111B64}.Debug|x64.Build.0 = Debug|x64
{40299226-5106-4793-A43D-9BBB17111B64}.Debug|x86.ActiveCfg = Debug|Win32
{40299226-5106-4793-A43D-9BBB17111B64}.Debug|x86.Build.0 = Debug|Win32
{40299226-5106-4793-A43D-9BBB17111B64}.Release|x64.ActiveCfg = Release|x64
{40299226-5106-4793-A43D-9BBB17111B64}.Release|x64.Build.0 = Release|x64
{40299226-5106-4793-A43D-9BBB17111B64}.Release|x86.ActiveCfg = Release|Win32
{40299226-5106-4793-A43D-9BBB17111B64}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
50 changes: 0 additions & 50 deletions RegistryHelper/RegistryHelper.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
#include "RegistryHelper.h"
#pragma once

#include <Windows.h>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>

class RegistryError : public std::runtime_error
{
public:
RegistryError(const std::string& message, DWORD errorCode)
: std::runtime_error(message + " Error Code: " + std::to_string(errorCode))
, m_errorCode(errorCode)
{
}

DWORD GetErrorCode() const { return m_errorCode; }

private:
DWORD m_errorCode;
};

class RegistryHelper
{
public:
RegistryHelper();

DWORD RegGetDword(HKEY hKey,
const std::wstring& subKey,
const std::wstring& value);

std::wstring RegGetString(HKEY hKey,
const std::wstring& subKey,
const std::wstring& value);

std::vector<std::wstring> RegGetMultiString(HKEY hKey,
const std::wstring& subKey,
const std::wstring& value);

std::vector<std::pair<std::wstring, DWORD>> RegEnumSubKeys(
HKEY hKey,
const std::wstring& subKey);

std::vector<std::pair<std::wstring, DWORD>> RegEnumValues(
HKEY hKey,
const std::wstring& subKey);

private:
DWORD m_errorCode;
};

// Constructor initializes the error code to ERROR_SUCCESS
RegistryHelper::RegistryHelper()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,22 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RegistryHelper.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="RegistryHelper.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{7144564f-fe5b-4b24-a6a9-c83f18969bbb}</ProjectGuid>
<RootNamespace>RegistryHelper</RootNamespace>
<ProjectGuid>{40299226-5106-4793-a43d-9bbb17111b64}</ProjectGuid>
<RootNamespace>RegistryInterface</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
Expand Down Expand Up @@ -76,20 +70,18 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<RunCodeAnalysis>true</RunCodeAnalysis>
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>
</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
Expand All @@ -99,12 +91,14 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>
</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -114,12 +108,14 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>
</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
Expand All @@ -129,17 +125,34 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>
</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="RegistryInterface.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="RegistryHelper.h" />
<ClCompile Include="RegistryInterface.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RegistryHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClInclude Include="framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RegistryInterface.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RegistryHelper.h">
<ClCompile Include="RegistryInterface.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RegistryHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
</ClCompile>
</ItemGroup>
</Project>

0 comments on commit c59a9ba

Please sign in to comment.