Réponse acceptée !
voici un code que j'avais fair pr un programme a moi en m'aidant entierement de la msdn:
[ Lien ]
[ Lien ]
Tas juste a mettre le nom du exe dans le char "nomExe".
------------------------------------------------------------------------------
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
char nomExe[20]="msnmsgr.exe";
int main(void)
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );/* Take a snapshot of all processes in the system.*/
Process32First( hProcessSnap, &pe32 );/* Retrieve information about the first process,*/
int conte=0;
do/* Now walk the snapshot of processes, and*/
{
/* récupère l'ID du process qui nous interresse !!! */
if( !strcmp(nomExe, pe32.szExeFile) )
{
DWORD lpExitCode;
hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
GetExitCodeProcess(hProcess,&lpExitCode);
TerminateProcess(hProcess,(UINT)lpExitCode);
}
} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );
return( TRUE );
}
------------------------------------------------------------------------------
MaLaDeDeDe 97one