| 251 | } |
| 252 | |
| 253 | wchar_t *find_windows_kit_root(HKEY key, wchar_t *version) { |
| 254 | // Given a key to an already opened registry entry, |
| 255 | // get the value stored under the 'version' subkey. |
| 256 | // If that's not the right terminology, hey, I never do registry stuff. |
| 257 | |
| 258 | DWORD required_length; |
| 259 | auto rc = RegQueryValueExW(key, version, NULL, NULL, NULL, &required_length); |
| 260 | if (rc != 0) return NULL; |
| 261 | |
| 262 | DWORD length = required_length + sizeof(wchar_t); // The extra wchar_t is for the maybe optional zero later on. Probably we are over-allocating. |
| 263 | wchar_t *value = (wchar_t *)malloc(length); |
| 264 | if (!value) return NULL; |
| 265 | |
| 266 | rc = RegQueryValueExW(key, version, NULL, NULL, (LPBYTE)value, &length); // We know that version is zero-terminated... |
| 267 | if (rc != 0) return NULL; |
| 268 | length /= sizeof(wchar_t); |
| 269 | |
| 270 | // The documentation says that if the string for some reason was not stored |
| 271 | // with zero-termination, we need to manually terminate it. Sigh!! |
| 272 | |
| 273 | if (value[length - 1]) { |
| 274 | value[length] = 0; |
| 275 | } |
| 276 | |
| 277 | return value; |
| 278 | } |
| 279 | |
| 280 | void win10_best(wchar_t *short_name, wchar_t *full_name, Version_Data *data) { |
| 281 | // Find the Windows 10 subdirectory with the highest version number. |
no test coverage detected