| 839 | } |
| 840 | |
| 841 | bool 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 | |
| 882 | bool isKeyEmpty(HKEY key) |
| 883 | { |
no test coverage detected