How to call function in procedure

Asked

Viewed 795 times

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.

1 answer

2


Simply call the function as follows

VerificaExistenciaDoProcesso('calc.exe');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.