This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
258 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,5 @@ jobs: | |
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Actions" | ||
git diff --exit-code || (git add -A && git commit -m "Auto-fix formatting issues") | ||
git push | ||
git push | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,70 @@ | ||
#include "RegistryHelper.h" | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
try | ||
{ | ||
RegistryHelper registryHelper; | ||
std::wstring subKey = L"SYSTEM\\CurrentControlSet\\Control"; | ||
HKEY hKey = HKEY_LOCAL_MACHINE; | ||
int main() { | ||
try { | ||
RegistryHelper registryHelper; | ||
std::wstring subKey = L"SYSTEM\\CurrentControlSet\\Control"; | ||
HKEY hKey = HKEY_LOCAL_MACHINE; | ||
|
||
// | ||
// Example 1: Reading DWORD value (REG_DWORD) | ||
// | ||
std::wstring valueNameDword = L"BootDriverFlags"; | ||
// | ||
// Example 1: Reading DWORD value (REG_DWORD) | ||
// | ||
std::wstring valueNameDword = L"BootDriverFlags"; | ||
|
||
DWORD dwordValue = registryHelper.RegGetDword(hKey, subKey, valueNameDword); | ||
std::wcout << L"DWORD Value: " << dwordValue << std::endl; | ||
DWORD dwordValue = registryHelper.RegGetDword(hKey, subKey, valueNameDword); | ||
std::wcout << L"DWORD Value: " << dwordValue << std::endl; | ||
|
||
// | ||
// Example 2: Reading String value (REG_SZ) | ||
// | ||
std::wstring valueNameString = L"CurrentUser"; | ||
// | ||
// Example 2: Reading String value (REG_SZ) | ||
// | ||
std::wstring valueNameString = L"CurrentUser"; | ||
|
||
std::wstring stringValue = registryHelper.RegGetString(hKey, subKey, valueNameString); | ||
std::wcout << L"String Value: " << stringValue << std::endl; | ||
std::wstring stringValue = | ||
registryHelper.RegGetString(hKey, subKey, valueNameString); | ||
std::wcout << L"String Value: " << stringValue << std::endl; | ||
|
||
// | ||
// Example 3: Reading Multi-String value (REG_MULTI_SZ) | ||
// | ||
std::wstring valueNameMultiString = L"PreshutdownOrder"; | ||
// | ||
// Example 3: Reading Multi-String value (REG_MULTI_SZ) | ||
// | ||
std::wstring valueNameMultiString = L"PreshutdownOrder"; | ||
|
||
std::vector<std::wstring> multiStringValue = | ||
registryHelper.RegGetMultiString(hKey, subKey, valueNameMultiString); | ||
std::vector<std::wstring> multiStringValue = | ||
registryHelper.RegGetMultiString(hKey, subKey, valueNameMultiString); | ||
|
||
std::wcout << L"Multi-String Values: " << std::endl; | ||
for (const auto& str : multiStringValue) | ||
{ | ||
std::wcout << L" " << str << std::endl; | ||
} | ||
std::wcout << L"Multi-String Values: " << std::endl; | ||
for (const auto &str : multiStringValue) { | ||
std::wcout << L" " << str << std::endl; | ||
} | ||
|
||
// | ||
// Example 4: Enumerate sub-keys | ||
// | ||
std::vector<std::pair<std::wstring, DWORD>> subKeys = registryHelper.RegEnumSubKeys(hKey, subKey); | ||
// | ||
// Example 4: Enumerate sub-keys | ||
// | ||
std::vector<std::pair<std::wstring, DWORD>> subKeys = | ||
registryHelper.RegEnumSubKeys(hKey, subKey); | ||
|
||
std::wcout << L"Sub-Keys: " << std::endl; | ||
for (const auto& subKeyPair : subKeys) | ||
{ | ||
std::wcout << L" " << subKeyPair.first << std::endl; | ||
} | ||
std::wcout << L"Sub-Keys: " << std::endl; | ||
for (const auto &subKeyPair : subKeys) { | ||
std::wcout << L" " << subKeyPair.first << std::endl; | ||
} | ||
|
||
// | ||
// Example 5: Enumerate values | ||
// | ||
std::vector<std::pair<std::wstring, DWORD>> values = registryHelper.RegEnumValues(hKey, subKey); | ||
// | ||
// Example 5: Enumerate values | ||
// | ||
std::vector<std::pair<std::wstring, DWORD>> values = | ||
registryHelper.RegEnumValues(hKey, subKey); | ||
|
||
std::wcout << L"Values: " << std::endl; | ||
for (const auto& valuePair : values) | ||
{ | ||
std::wcout << L" " << valuePair.first << L" (Type: " << valuePair.second << L")" << std::endl; | ||
} | ||
} | ||
catch (const RegistryError& ex) | ||
{ | ||
std::cerr << "Registry Error: " << ex.what() << " (Error Code: " << ex.ErrorCode() << ")" << std::endl; | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
std::cerr << "Error: " << ex.what() << std::endl; | ||
} | ||
std::wcout << L"Values: " << std::endl; | ||
for (const auto &valuePair : values) { | ||
std::wcout << L" " << valuePair.first << L" (Type: " << valuePair.second | ||
<< L")" << std::endl; | ||
} | ||
} catch (const RegistryError &ex) { | ||
std::cerr << "Registry Error: " << ex.what() | ||
<< " (Error Code: " << ex.ErrorCode() << ")" << std::endl; | ||
} catch (const std::exception &ex) { | ||
std::cerr << "Error: " << ex.what() << std::endl; | ||
} | ||
|
||
return 0; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.