int KillTask(String FileName)

{

  bool ContinueLoop;

  HANDLE FSnapshotHandle;

  PROCESSENTRY32 FProcessEntry32;

  FSnapshotHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);

  FProcessEntry32.dwSize = sizeof(FProcessEntry32);

  ContinueLoop = Process32First(FSnapshotHandle, &FProcessEntry32);

  while(ContinueLoop)

    {

      if((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) == UpperCase(FileName))

      || (UpperCase(FProcessEntry32.szExeFile) == UpperCase(FileName)))

        {

          // retorna um se tiver êxito ou zero, se falhar

          return TerminateProcess(OpenProcess(PROCESS_TERMINATE, 0, FProcessEntry32.th32ProcessID),0);

        }

      ContinueLoop = Process32Next(FSnapshotHandle, &FProcessEntry32);

    }

  CloseHandle(FSnapshotHandle);

  return 0;

}