まず、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