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.