BOOL TerminateProcess(HANDLE HandleProcessus, UINT CodeRetour);
#include <windows.h>
#include <winbase.h>
char Programme[100];
char Parametres[100];
char RepertoireInitial[100];
STARTUPINFO InformationDemarrage;
PROCESS_INFORMATION InformationProcessus;
...
InformationDemarrage.cb=sizeof(STARTUPINFOW);
InformationDemarrage.lpReserved=NULL;
InformationDemarrage.lpDesktop=NULL;
InformationDemarrage.lpTitle=NULL;
InformationDemarrage.dwX=0;
InformationDemarrage.dwY=0;
InformationDemarrage.dwXSize=0;
InformationDemarrage.dwYSize=0;
InformationDemarrage.dwXCountChars=0;
InformationDemarrage.dwYCountChars=0;
InformationDemarrage.dwFillAttribute=0;
InformationDemarrage.wShowWindow=SW_SHOW;
InformationDemarrage.cbReserved2=0;
InformationDemarrage.lpReserved2=0;
InformationDemarrage.hStdInput=GetStdHandle(STD_INPUT_HANDLE);
InformationDemarrage.hStdOutput=GetStdHandle(STD_OUTPUT_HANDLE);
InformationDemarrage.hStdError=GetStdHandle(STD_ERROR_HANDLE);
InformationDemarrage.dwFlags=STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
InformationProcessus.hProcess=NULL;
InformationProcessus.hThread=NULL;
InformationProcessus.dwProcessId=0;
InformationProcessus.dwThreadId=0;
if (!CreateProcess((LPCSTR)Programme, (LPCSTR)Parametres, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL, (LPCSTR)RepertoireInitial, &InformationDemarrage, &InformationProcessus))
{
...
}
...
if (!TerminateProcess(InformationProcessus.hProcess, 0))
{
...
}
...
TerminateThread pour terminer un thread.