// findqt.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include #include #include #include #include #include static INTER_MODULE_CALLBACK(got_wstr) { *((std::wstring*)param) += std::wstring((const wchar_t*)data, len / 2); return inter_module_data::SET_RESULT_CONTINUE; } static INTER_MODULE_CALLBACK(got_str) { *((std::string*)param) += std::string(data, len); return inter_module_data::SET_RESULT_CONTINUE; } int main() { std::wstring path(L""); sys_util::reg_get_string(HKEY_CLASSES_ROOT, L"QtProject.QtCreator.pro\\shell\\Open\\Command", NULL, got_wstr, &path); if (path.empty()) return -1; std::transform(path.begin(), path.end(), path.begin(), tolower); size_t pos = path.find(L".exe"); if (pos == std::wstring::npos) return -2; pos += 4; if (pos < path.length()) { if (path[pos] == L' ') path.erase(pos); else return -3; } STR_PARENT_FOLDER(path); STR_PARENT_FOLDER(path); STR_PARENT_FOLDER(path); STR_PARENT_FOLDER(path); file_util::IFileFinder* finder = file_util::create_file_finder(); file_util::PATHFILE found = { 0 }; bool ok = false; if (finder->find_first(path.c_str(), &found) == 0) { do { std::transform(found.path, found.path + lstrlenW(found.path), found.path, tolower); if (wcsstr(found.path, L"\\qmake.exe")) { if (wcsstr(found.path, L"\\msvc") && !wcsstr(found.path, L"_64") && !wcsstr(found.path, L"_x64")) { ok = true; break; } } } while (finder->find_next(&found) == 0); } finder->release(); if (!ok) return -4; sys_util::reg_set_string(HKEY_CURRENT_USER, L"Software\\Qt", L"qmake", found.path); std::wcout << found.path << std::endl; return 0; } // 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单 // 调试程序: F5 或调试 >“开始调试”菜单 // 入门使用技巧: // 1. 使用解决方案资源管理器窗口添加/管理文件 // 2. 使用团队资源管理器窗口连接到源代码管理 // 3. 使用输出窗口查看生成输出和其他消息 // 4. 使用错误列表窗口查看错误 // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件