1
function TForm1.VerificaExistenciaDoProcesso(NomeProcesso: String): Boolean;
var
  Continue: Boolean;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
  begin
    Result := False;
    FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
    Continue := Process32First(FSnapshotHandle,FProcessEntry32);
    while Integer(Continue) <> 0 do
    begin
      if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
             UpperCase(NomeProcesso)) or
              (UpperCase(FProcessEntry32.szExeFile) =
                 UpperCase(NomeProcesso))) then
      begin
        Result := True;
        Exit;
      end;
      Continue := Process32Next(FSnapshotHandle,FProcessEntry32);
    end;
    CloseHandle(FSnapshotHandle);
end;






procedure TForm1.Button1Click(Sender: TObject);
begin
      VerificaExistenciaDoProcesso('calc.exe'):Boolean;
end;

end.
2

1 Resposta 1

2

Basta você simplesmente chamar a função da seguinte forma

VerificaExistenciaDoProcesso('calc.exe');

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .