Fix microsoft_craziness.h

This commit is contained in:
gingerBill
2020-01-18 12:08:45 +00:00
parent c3a8e232a5
commit 23ff98dea0
+10 -17
View File
@@ -398,6 +398,7 @@ bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
// If all this COM object instantiation, enumeration, and querying doesn't give us
// a useful result, we drop back to the registry-checking method.
auto rc = CoInitialize(NULL);
// "Subsequent valid calls return false." So ignore false.
if (rc != S_OK) return false;
@@ -408,7 +409,7 @@ bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
ISetupConfiguration *config = NULL;
HRESULT hr = 0;
hr = CoCreateInstance(CLSID_SetupConfiguration, NULL, CLSCTX_INPROC_SERVER, my_uid, (void **)&config);
if (hr != 0) return false;
if (hr == 0) {
defer (config->Release());
IEnumSetupInstances *instances = NULL;
@@ -417,7 +418,6 @@ bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
if (!instances) return false;
defer (instances->Release());
for (;;) {
ULONG found = 0;
ISetupInstance *instance = NULL;
@@ -475,21 +475,21 @@ bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
So... @Incomplete: Should probably pick the newest version...
*/
}
}
// If we get here, we didn't find Visual Studio 2017. Try earlier versions.
{
HKEY vs7_key;
rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &vs7_key);
if (rc != S_OK) return false;
defer (RegCloseKey(vs7_key));
// Hardcoded search for 4 prior Visual Studio versions. Is there something better to do here?
wchar_t *versions[] = { L"14.0", L"12.0", L"11.0", L"10.0" };
wchar_t *versions[] = { L"14.0", L"13.0", L"12.0", L"11.0", L"10.0", L"9.0", };
const int NUM_VERSIONS = sizeof(versions) / sizeof(versions[0]);
for (int i = 0; i < NUM_VERSIONS; i++) {
auto v = versions[i];
wchar_t *v = versions[i];
DWORD dw_type;
DWORD cb_data;
@@ -508,14 +508,14 @@ bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
// @Robustness: Do the zero-termination thing suggested in the RegQueryValue docs?
auto lib_path = concat(buffer, L"VC\\Lib\\amd64");
auto lib_path = concat(buffer, L"VC\\Lib\\amd64\\");
// Check to see whether a vcruntime.lib actually exists here.
auto vcruntime_filename = concat(lib_path, L"\\vcruntime.lib");
auto vcruntime_filename = concat(lib_path, L"vcruntime.lib");
defer (free(vcruntime_filename));
if (os_file_exists(vcruntime_filename)) {
result->vs_exe_path = concat(buffer, L"VC\\bin");
result->vs_exe_path = concat(buffer, L"VC\\bin\\");
result->vs_library_path = lib_path;
return true;
}
@@ -524,6 +524,7 @@ bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
}
// If we get here, we failed to find anything.
}
return false;
}
@@ -568,13 +569,5 @@ Find_Result_Utf8 find_visual_studio_and_windows_sdk_utf8() {
r.vs_exe_path = mc_wstring_to_string(result.vs_exe_path);
r.vs_library_path = mc_wstring_to_string(result.vs_library_path);
// gb_printf("%.*s\n", LIT(r.windows_sdk_root));
// gb_printf("%.*s\n", LIT(r.windows_sdk_um_library_path));
// gb_printf("%.*s\n", LIT(r.windows_sdk_ucrt_library_path));
// gb_printf("%.*s\n", LIT(r.vs_exe_path));
// gb_printf("%.*s\n", LIT(r.vs_library_path));
// gb_exit(1);
return r;
}