添加传递命令行的功能

This commit is contained in:
fanbook-wangdage
2026-01-13 16:32:19 +08:00
parent 6ffd594367
commit 6ff11aeb26
2 changed files with 10 additions and 1 deletions

View File

@@ -682,7 +682,15 @@ int main(int argc, char** argv)
STARTUPINFOA si{};
PROCESS_INFORMATION pi{};
if (!CreateProcessA(ProcessPath.c_str(), (LPSTR)CommandLine.c_str(), nullptr, nullptr, FALSE, 0, nullptr, ProcessDir.c_str(), &si, &pi))
// 构建完整的命令行:可执行文件路径 + 参数
std::string FullCommandLine = "\"" + ProcessPath + "\"";
if (!CommandLine.empty())
{
FullCommandLine += " " + CommandLine;
}
if (!CreateProcessA(nullptr, (LPSTR)FullCommandLine.c_str(), nullptr, nullptr, FALSE, 0, nullptr, ProcessDir.c_str(), &si, &pi))
{
DWORD code = GetLastError();
printf("CreateProcess failed (%d): %s", code, GetLastErrorAsString(code).c_str());