As a rule you should not close CE when you detect it presence, instead you should close your own program. Like this:
Code:
void CheckCEPresent(){
HANDLE hSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, NULL )
PROCESSENTRY32 p = { NULL };
if( hSnap == INVALID_HANDLE_VALUE ){
printf("Error: Failed to open a snapshot of all the processes running\n");
return;
}
if( !Process32First( hSnap, &p ) ){
printf("Error: Failed to enumerate first process running\n");
}
do{
if( !strcmp( (char*)&p.szExeFile, "ce.exe" ) ){ // strcmp returns 0 when the strings are equal
printf("CE.exe found, exiting!\n");
exit( 0 );
}
} while( Process32Next( hSnap, &p ) );
}
I wrote this from the top of my head, but this is the general idea. Simply execute this function every few seconds, once CE shows up in your process list the program exits.