Вы используете его для передачи аргументов в .exe, определенный первым параметром:
Примером может быть вызов cmd.exe, а затем запуск скрипта или использование утилиты zip:
void runCmd(const tstring& cmdString, STARTUPINFO &si, PROCESS_INFORMATION &pi)
{
ZeroMemory( &si, sizeof(si) );
ZeroMemory( &pi, sizeof(pi) );
si.cb = sizeof(si);
tstring cmd_exe_path(win_dir);
cmd_exe_path.append( _T("\\System32\\") ).append(CMD_PROCESS);
tstring argline( _T("/c ") );
argline += cmdString;
tstring curr_dir( cmdString.substr( 0, cmdString.rfind( _T('.') ) ) );
curr_dir.erase( curr_dir.find_last_of( _T("/\\") ) );
size_t pos = curr_dir.find( _T("\"") );
while( pos != tstring::npos )
{
curr_dir.erase( pos, pos + 1 );
pos = curr_dir.find( _T("\"") );
}
//USE FULL PATHS FOR SAFETY... Include wrapping quotes if spaces required in path
LOG(LOG_INFO,_T("runCmd(): Calling %s %s Dir[ %s ]"),cmd_exe_path.c_str(),argline.c_str(), curr_dir.c_str());
if( !CreateProcess( cmd_exe_path.c_str(), &argline[0], NULL, NULL, FALSE, CREATE_NEW_CONSOLE,
NULL,curr_dir.c_str(),&si,&pi ) ) //this generates warning C6335 - resource leak... however handles should be closed by owner
{
DWORD dw = GetLastError();
std::string error( "runCmd(): Failed to create Shutdown process - error code is " );
error.append(boost::lexical_cast<std::string>(dw));
LOG(LOG_INFO,error.c_str());
throw std::exception(error.c_str());
}
LOG(LOG_INFO,"runCmd(): process starting with PID[%d] TID[%d]",pi.dwProcessId,pi.dwThreadId);
}