diff --git a/tools/apps/findqt/findqt.cpp b/tools/apps/findqt/findqt.cpp new file mode 100644 index 0000000..5f1f808 --- /dev/null +++ b/tools/apps/findqt/findqt.cpp @@ -0,0 +1,88 @@ +// 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 文件 diff --git a/tools/apps/findqt/findqt.vcxproj b/tools/apps/findqt/findqt.vcxproj new file mode 100644 index 0000000..287f366 --- /dev/null +++ b/tools/apps/findqt/findqt.vcxproj @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {1f4bf993-302e-4728-b044-39dc8644c1cc} + findqt + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(OutDir)$(ProjectName)\ + $(SolutionDir)..\sdk\include;$(IncludePath) + $(SolutionDir)..\sdk\lib;$(LibraryPath) + + + false + $(OutDir)$(ProjectName)\ + $(SolutionDir)..\sdk\include;$(IncludePath) + $(SolutionDir)..\sdk\lib;$(LibraryPath) + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/tools/apps/findqt/findqt.vcxproj.filters b/tools/apps/findqt/findqt.vcxproj.filters new file mode 100644 index 0000000..99866aa --- /dev/null +++ b/tools/apps/findqt/findqt.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + \ No newline at end of file diff --git a/tools/solution/Release/findqt.exe b/tools/solution/Release/findqt.exe new file mode 100644 index 0000000..8433ade Binary files /dev/null and b/tools/solution/Release/findqt.exe differ diff --git a/tools/solution/sane_tools.sln b/tools/solution/sane_tools.sln index 1d79cf7..72bef68 100644 --- a/tools/solution/sane_tools.sln +++ b/tools/solution/sane_tools.sln @@ -9,6 +9,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hgjson", "..\apps\hgjson\hg EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cvstr", "..\apps\cvstr\cvstr.vcxproj", "{758032ED-6FB3-4E7F-AA8F-A463C2B5D91E}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "findqt", "..\apps\findqt\findqt.vcxproj", "{1F4BF993-302E-4728-B044-39DC8644C1CC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Mixed Platforms = Debug|Mixed Platforms @@ -49,6 +51,22 @@ Global {758032ED-6FB3-4E7F-AA8F-A463C2B5D91E}.Release|x64.ActiveCfg = Release|Win32 {758032ED-6FB3-4E7F-AA8F-A463C2B5D91E}.Release|x86.ActiveCfg = Release|Win32 {758032ED-6FB3-4E7F-AA8F-A463C2B5D91E}.Release|x86.Build.0 = Release|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|Win32.ActiveCfg = Debug|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|Win32.Build.0 = Debug|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|x64.ActiveCfg = Debug|x64 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|x64.Build.0 = Debug|x64 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|x86.ActiveCfg = Debug|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Debug|x86.Build.0 = Debug|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|Mixed Platforms.Build.0 = Release|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|Win32.ActiveCfg = Release|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|Win32.Build.0 = Release|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|x64.ActiveCfg = Release|x64 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|x64.Build.0 = Release|x64 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|x86.ActiveCfg = Release|Win32 + {1F4BF993-302E-4728-B044-39DC8644C1CC}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -56,6 +74,7 @@ Global GlobalSection(NestedProjects) = preSolution {D3579C48-F5AB-4F15-9B49-A2970FBA76C5} = {434BA17E-2347-4C76-97A2-DF9940EEB9FC} {758032ED-6FB3-4E7F-AA8F-A463C2B5D91E} = {434BA17E-2347-4C76-97A2-DF9940EEB9FC} + {1F4BF993-302E-4728-B044-39DC8644C1CC} = {434BA17E-2347-4C76-97A2-DF9940EEB9FC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8F4909F0-C507-4210-A730-BFFBF9773850}