TerminateProcess

Prototypes

BOOL TerminateProcess(HANDLE HandleProcessus, UINT CodeRetour);

Description

Termine le processus identifié par le handle HandleProcessus avec le code retour CodeRetour.

Exemple

#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)) ...

Avertissement

Le résultat est Faux en cas d'erreur.

Voir aussi

CreateProcess pour créer un processus. GetExitCodeProcess pour lire le code retour du processus créé.

TerminateThread pour terminer un thread.