1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
// Ligne de commande :
string cmdLine = "ligne de commande...";
// Création d'un buffer pour la ligne de commande : (pas obligé de passer par boost)
scoped_array<char> cmdLineBuffer(new char[cmdLine.size() + 1]);
copy(cmdLine.data(), cmdLine.data() + cmdLine.size() + 1, cmdLineBuffer.get());
// Information sur le demarage du process : (cf MSDN)
STARTUPINFO startupInfo;
memset(&startupInfo, 0, sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.wShowWindow = SW_MINIMIZE;
// Information sur le process : (cf MSDN)
PROCESS_INFORMATION processInfo = { NULL, NULL, 0, 0 };
// Lancement :
if(FALSE == CreateProcess(0, cmdLineBuffer.get(), 0, 0, FALSE, CREATE_NEW_CONSOLE, 0, 0, &startupInfo, &processInfo)) {
DWORD error = GetLastError();
cout << "System error = " << error;
}
CloseHandle(processInfo.hThread); |
Partager