MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / forEachSubKey

Function forEachSubKey

src/env.cpp:841–880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841bool forEachSubKey(HKEY key, std::function<bool(const wchar_t* name)> f)
842{
843 auto name = std::make_unique<wchar_t[]>(1000 + 1);
844 DWORD nameSize = 1000;
845
846 DWORD i = 0;
847
848 // something would be really wrong if it had more than 100 keys
849 while (i < 100) {
850 auto r = ::RegEnumKeyExW(key, i, name.get(), &nameSize, nullptr, nullptr, nullptr,
851 nullptr);
852
853 if (r == ERROR_NO_MORE_ITEMS) {
854 // no more subkeys
855 break;
856 }
857
858 if (r == ERROR_SUCCESS) {
859 // a subkey exists
860 auto subkey = openRegistryKey(key, name.get());
861
862 if (!subkey) {
863 // can't open it, stop
864 return false;
865 }
866
867 // fire callback
868 if (!f(name.get())) {
869 return false;
870 }
871 } else {
872 // something went wrong, stop
873 return false;
874 }
875
876 ++i;
877 }
878
879 return true;
880}
881
882bool isKeyEmpty(HKEY key)
883{

Callers 1

isKeyEmptyFunction · 0.85

Calls 2

openRegistryKeyFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected