| 880 | } |
| 881 | |
| 882 | bool isKeyEmpty(HKEY key) |
| 883 | { |
| 884 | // check for any values |
| 885 | if (keyHasValues(key)) { |
| 886 | return false; |
| 887 | } |
| 888 | |
| 889 | auto r = forEachSubKey(key, [&](const wchar_t* name) { |
| 890 | // a subkey exists, recursively check if it's empty |
| 891 | auto subkey = openRegistryKey(key, name); |
| 892 | |
| 893 | if (!subkey) { |
| 894 | // can't open, stop |
| 895 | return false; |
| 896 | } |
| 897 | |
| 898 | if (!isKeyEmpty(subkey.get())) { |
| 899 | // not empty, stop |
| 900 | return false; |
| 901 | } |
| 902 | |
| 903 | // empty, go on |
| 904 | return true; |
| 905 | }); |
| 906 | |
| 907 | if (!r) { |
| 908 | // something went wrong or some subkey has values |
| 909 | return false; |
| 910 | } |
| 911 | |
| 912 | // key has no values and has either no subkeys or all subkeys are empty |
| 913 | return true; |
| 914 | } |
| 915 | |
| 916 | void deleteRegistryKeyIfEmpty(const QString& name) |
| 917 | { |
no test coverage detected