{"id":26286850,"url":"https://github.com/m4x1m1l14n/registry","last_synced_at":"2025-08-12T05:15:50.555Z","repository":{"id":143765093,"uuid":"165055732","full_name":"m4x1m1l14n/Registry","owner":"m4x1m1l14n","description":"C++ wrapper for manipulating Windows registry","archived":false,"fork":false,"pushed_at":"2023-07-19T07:48:08.000Z","size":36,"stargazers_count":54,"open_issues_count":4,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T17:03:25.123Z","etag":null,"topics":["c-plus-plus","c-plus-plus-11","cpp","cpp11","library","registry","win32","win32-api","win32api","windows","windows-registry"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m4x1m1l14n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"m4x1m1l14n"}},"created_at":"2019-01-10T12:25:16.000Z","updated_at":"2025-04-29T13:39:40.000Z","dependencies_parsed_at":"2024-01-14T06:56:07.820Z","dependency_job_id":null,"html_url":"https://github.com/m4x1m1l14n/Registry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/m4x1m1l14n/Registry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4x1m1l14n%2FRegistry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4x1m1l14n%2FRegistry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4x1m1l14n%2FRegistry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4x1m1l14n%2FRegistry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m4x1m1l14n","download_url":"https://codeload.github.com/m4x1m1l14n/Registry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4x1m1l14n%2FRegistry/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270005591,"owners_count":24510939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","c-plus-plus-11","cpp","cpp11","library","registry","win32","win32-api","win32api","windows","windows-registry"],"created_at":"2025-03-14T20:39:46.647Z","updated_at":"2025-08-12T05:15:50.530Z","avatar_url":"https://github.com/m4x1m1l14n.png","language":"C++","funding_links":["https://github.com/sponsors/m4x1m1l14n","https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=WZ5UGW93SUEA8\u0026currency_code=EUR\u0026amount=5\u0026source=url"],"categories":[],"sub_categories":[],"readme":"[![Build status](https://ci.appveyor.com/api/projects/status/3nvam4ye0yhtt5kt?svg=true)](https://ci.appveyor.com/project/m4x1m1l14n/registry)\r\n[![Coverage Status](https://coveralls.io/repos/github/m4x1m1l14n/Registry/badge.svg?branch=master)](https://coveralls.io/github/m4x1m1l14n/Registry?branch=master)\r\n\r\nSaved a little time of your life? :beer::sunglasses::thumbsup: \r\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=WZ5UGW93SUEA8\u0026currency_code=EUR\u0026amount=5\u0026source=url)\r\n\r\n# Registry namespace\r\n\r\nC++ class for manipulating Windows Registry.\r\nWraps \u0026 simplifies native Windows API and combines it with power of modern C++11.\r\n\r\n[//]: # \"Source code documentation to whole namespace can be found on [http://www.nanosoft.sk](http://www.nanosoft.sk)\"\r\n\r\n## Table of contents\r\n* [Table of contents](#table-of-contents)\r\n* [Root registry keys](#root-registry-keys)\r\n* [Opening registry keys](#opening-registry-keys)\r\n* [Creating registry keys](#creating-registry-keys)\r\n* [Deleting registry key](#deleting-registry-key)\r\n* [Flush registry](#flush-registry)\r\n* [Save registry key to file](#save-registry-key-to-file)\r\n* [Check if registry key exists](#check-if-registry-key-exists)\r\n* [Check if registry value exists](#check-if-registry-value-exists)\r\n* [Save boolean value to registry](#save-boolean-value-to-registry)\r\n* [Read boolean value from registry](#read-boolean-value-from-registry)\r\n* [Save integer value to registry](#save-integer-value-to-registry)\r\n* [Read integer value from registry](#read-integer-value-from-registry)\r\n* [Save string value to registry](#save-string-value-to-registry)\r\n* [Read string value from registry](#read-string-value-from-registry)\r\n* [Enumerating registry subkeys](#enumerating-registry-subkeys)\r\n\r\n\u003e**NOTE:**  \r\n\u003e All methods can throw exceptions, if system error occurs!\r\n\u003e\r\n\u003e All exceptions thrown are derived from std::exception class, so don't forget to wrap your code with try / catch block.\r\n\r\n## Root registry keys\r\n\r\nFollowing windows registry root keys are predefined within Registry namespace, and can be accessed directly in your code\r\n\r\n```C++\r\nRegistry::ClassesRoot\r\nRegistry::CurrentUser\r\nRegistry::LocalMachine\r\nRegistry::Users\r\nRegistry::CurrentConfig\r\n```\r\n\r\n## Opening registry keys\r\n\r\nExisting windows registry key can be opened simply by call to RegistryKey\\:\\:Open() method specifying path to registry key.\r\n\r\n\u003e**NOTE:**  \r\n\u003e Registry key is closed automatically when RegistryKey object goes out of scope.\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\");\r\n\r\n        // do work needed\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n    \t// handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\nRegistry key is by default opened with read access, same as if you open registry key as follows\r\n\r\n```C++\r\nauto access = Registry::DesiredAccess::Read;\r\n\r\nauto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\", access);\r\n```\r\n\r\nDesired access for opening registry keys can be combined\r\n\r\n```C++\r\nauto access = Registry::DesiredAccess::Read | Registry::DesiredAccess::Write;\r\n\t\t\r\nauto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\", access);\r\n```\r\n\r\n## Creating registry keys\r\n\r\nRegistry keys can be created in a same way as if they are opened.\r\n\r\nSimply by using RegistryKey::Create() method. Usage is same as when opening keys.\r\n\r\n\u003e **NOTE:**  \r\n\u003e You must have sufficient privileges to create registry keys under specific root key.\r\n\u003e In other case std::system_error exception will be thrown\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto access = Registry::DesiredAccess::Read | Registry::DesiredAccess::Write;\r\n\r\n        auto key = Registry::LocalMachine-\u003eCreate(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\", access);\r\n\r\n        // do work needed\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\nRegistryKey can be created also from native windows registry key handle HKEY.\r\n\r\n\u003e **NOTE:**  \r\n\u003e In case hKey is nullptr, std::invalid_argument is thrown\r\n\r\n```C++\r\nRegistry::RegistryKey_ptr key = std::make_shared\u003cRegistry::RegistryKey\u003e(hKey);\r\n```\r\n\r\n## Using with native API\r\n\r\nRegistryKey has HKEY() operator overloaded, thus can be used with conjunction with native Windows registry API.\r\n\r\nUsage is as follows\r\n\r\n```C++\r\nauto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\");\r\n\r\nDWORD dwValue = 0;\r\nDWORD cbData = sizeof(dwValue);\r\nDWORD dwType;\r\n\r\nLSTATUS lStatus = RegQueryValueEx(*key, L\"SomeDWORDValue\", nullptr, \u0026dwType, reinterpret_cast\u003cLPBYTE\u003e(\u0026dwValue), \u0026cbData);\r\nif (lStatus == ERROR_SUCCESS)\r\n{\r\n    // DO SOMETHING\r\n}\r\n```\r\n\r\n## Deleting registry key\r\n\r\n## Flush registry\r\n\r\n## Save registry key to file\r\n\r\n## Check if registry key exists\r\n\r\nHasKey() or Exists() methods can be used to check, whether registry key contains specified subkey.\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eCreate(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\");\r\n        if (key-\u003eHasKey(L\"SomeSubKey\"))\r\n        {\r\n            // TRUE\r\n        }\r\n        else\r\n        {\r\n            // FALSE\r\n        }\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Check if registry value exists\r\n\r\nTo check if windows registry key contains specific value use HasValue() method as follows\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eCreate(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\");\r\n        if (key-\u003eHasValue(L\"Version\"))\r\n        {\r\n            // TRUE\r\n        }\r\n        else\r\n        {\r\n            // FALSE\r\n        }\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Save boolean value to registry\r\n\r\nTo save boolean value to registry, use SetBoolean() method as follows\r\n\r\n\u003e **NOTE:**  \r\n\u003e Boolean value is stored in registry as REG_DWORD. 0 for false and 1 for true.\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eCreate(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\");\r\n\t\t\r\n        key-\u003eSetBoolean(L\"EnableLogger\", true);\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Read boolean value from registry\r\n\r\nTo read boolean value from registry use GetBoolean() method as follows\r\n\r\n\u003e **NOTE:**  \r\n\u003e RegistryKey class use REG_DWORD registry value data type to work with boolean value.\r\n\u003e If registry value is 0, false is returned. If registry value is above 0, value of true is returned.\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eCreate(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\");\r\n        auto enabled = key-\u003eGetBoolean(L\"EnableLogger\");\r\n        if (enabled)\r\n        {\r\n            // do work\r\n        }\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Save integer value to registry\r\n\r\nTo save signed / unsigned integer values to registry, use one of methods \r\n\r\n* SetInt32()\r\n* SetUInt32()\r\n* SetInt64()\r\n* SetUInt64()\r\n\r\nas follows\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto access = Registry::DesiredAccess::Write;\r\n\r\n        auto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\\\\Logger\", access);\r\n\t\t\r\n        key-\u003eSetInt32(L\"Severity\", -3);\r\n        key-\u003eSetUInt32(L\"Timeout\", 10000);\r\n\r\n        key-\u003eSetInt64(L\"SomeBigNumber\", -9223372036854775808);\r\n        key-\u003eSetUInt64(L\"Id\", 0xf0f0f0f0f0f0f0f0);\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Read integer value from registry\r\n\r\nTo read signed / unsigned integer values from registry, use one of methods\r\n\r\n* GetInt32()\r\n* GetUInt32()\r\n* GetInt64()\r\n* GetUInt64()\r\n\r\nas follows\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\\\\Logger\");\r\n\t\t\r\n        std::cout \u003c\u003c key-\u003eGetInt32(L\"Severity\")         \u003c\u003c std::endl;\r\n        std::cout \u003c\u003c key-\u003eGetUInt32(L\"Timeout\")         \u003c\u003c std::endl;\r\n        std::cout \u003c\u003c key-\u003eGetInt64(L\"SomeBigNumber\")    \u003c\u003c std::endl;\r\n        std::cout \u003c\u003c key-\u003eGetUInt64(L\"Id\")              \u003c\u003c std::endl;\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Save string value to registry\r\n\r\nTo save string value to registry use SetString() method as follows\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto access = Registry::DesiredAccess::Write;\r\n\r\n        auto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\\\\Logger\", access);\r\n\t\t\r\n        key-\u003eSetString(L\"FileName\", L\"c:\\\\Program Files\\\\MyCompany\\\\MyApplication\\\\log.txt\");\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Read string value from registry\r\n\r\nTo read string value from windows registry use GetString() method as follows\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\\\\Logger\");\r\n\t\t\r\n        auto logFileName = key-\u003eGetString(L\"FileName\");\r\n\r\n        // work with read value\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Save expandable string value to registry\r\n\r\nTo save string value to registry use SetExpandString() method in same manner as SetString().\r\n\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto access = Registry::DesiredAccess::Write;\r\n\r\n        auto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\MyCompany\\\\MyApplication\\\\Logger\", access);\r\n\t\t\r\n        key-\u003eSetExpandString(L\"InstallDir\", L\"%ProgramFiles%\\\\My Company\\\\My Product\\\\\");\r\n    }\r\n    catch (const std::exception\u0026)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n\r\n## Enumerating registry subkeys\r\n\r\nEumerating registry key subkeys is done as follows, using lambda expression\r\n\r\n```C++\r\n#include \u003cRegistry.hpp\u003e\r\n\r\nusing namespace m4x1m1l14n;\r\n\r\nint main()\r\n{\r\n    try\r\n    {\r\n        auto key = Registry::LocalMachine-\u003eOpen(L\"SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\");\r\n\r\n        key-\u003eEnumerateSubKeys([](const std::wstring\u0026 name) -\u003e bool\r\n        {\r\n            // Process subkey\r\n            std::wcout \u003c\u003c name \u003c\u003c std::endl;\r\n\r\n            // Return true to continue processing, false otherwise\r\n            return true;\r\n        });\r\n    }\r\n    catch (const std::exception\u0026 ex)\r\n    {\r\n        // handle thrown exception\r\n    }\r\n\r\n    return 0;\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4x1m1l14n%2Fregistry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm4x1m1l14n%2Fregistry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4x1m1l14n%2Fregistry/lists"}