首先,您的std::vector::push_back
调用需要字符串。
list.push_back("eeee -q 50 kekekekkee.jpg -o kdkdkdkdd.jpg");
list.push_back("eeee -q 50 kefffffee.jpg -o kefffffee.jpg");
list.push_back("eeee -q 50 kfffffff.jpg -o kfffffff.jpg");
list.push_back("eeee -q 50 kekeksfwefee.jpg -o kekeksfwefee.jpg");
然后,只需通过矢量
for(auto&& ProcessArgs : list)
{
// So about CreateProcessA, it is a wrapper for CreateProcessW.
// Normally the string being fed into CreateProcess must be mutable, but
// in the case of CreateProcessA, a copy is made and converted to unicode to
// call CreateProcessW. Meaning we can give our string directly from
// the std::string without needing to make a copy.
// However, the way to do that is to use const_cast to remove the
// constness of std::string::c_str, so lets not and make a copy
// anyway, because const_cast is bad practice.
std::unique_ptr<char*> spString(new char[ProcessArgs.length() + 1]());
std::copy(ProcessArgs.begin(), ProcessArgs.end(), spString.get());
if (CreateProcessA(NULL, spString.get(), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
{
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
}
来源
2016-07-28 14:36:14
lcs
“脚本”?那里有可用的C++脚本引擎吗? –
这些'eeee -q 50 kekekekkee.jpg -o kdkdkdkdd.jpg'行有什么样的语法? –
我通常使用命令行参数来表示这是单个字符串参数。如果你有启动程序的源代码,你也可以在你的命令行参数中添加一个文件选项,然后把所有其他命令行参数放在你的应用程序生成的文件中,该文件需要调用CreateProcess()。 – drescherjm