From ef69a28beda4b1fc92256d94023793d8ec0737f1 Mon Sep 17 00:00:00 2001 From: triton Date: Sun, 11 Aug 2013 19:13:13 +0100 Subject: [PATCH] Improved VS paths lookup checking. This fixes a bug that happened when you had multiple versions of VS installed and your highest version did not provide the native development SDK. --- src/Parser/VSLookup.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Parser/VSLookup.cpp b/src/Parser/VSLookup.cpp index c55a964b..9974fcd6 100644 --- a/src/Parser/VSLookup.cpp +++ b/src/Parser/VSLookup.cpp @@ -92,7 +92,19 @@ static bool getSystemRegistryString(const char *keyPath, const char *valueName, strncpy(numBuf, sp, sizeof(numBuf) - 1); numBuf[sizeof(numBuf) - 1] = '\0'; double value = strtod(numBuf, NULL); - if (value > bestValue) { + + // Check if InstallDir key value exists. + bool isViableVersion = false; + + lResult = RegOpenKeyExA(hTopKey, keyName, 0, KEY_READ, &hKey); + if (lResult == ERROR_SUCCESS) { + lResult = RegQueryValueExA(hKey, valueName, NULL, NULL, NULL, NULL); + if (lResult == ERROR_SUCCESS) + isViableVersion = true; + RegCloseKey(hKey); + } + + if (isViableVersion && (value > bestValue)) { bestIndex = (int)index; bestValue = value; strcpy(bestName, keyName);