MCPcopy Create free account
hub / github.com/beefytech/Beef / find_windows_kit_root

Function find_windows_kit_root

IDEHelper/VSSupport.cpp:253–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253wchar_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
280void win10_best(wchar_t *short_name, wchar_t *full_name, Version_Data *data) {
281 // Find the Windows 10 subdirectory with the highest version number.

Callers 1

Calls 4

concatFunction · 0.85
visit_files_wFunction · 0.85
mallocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected