All necessary expenses incurred by the district attorneys of any county of this Commonwealth or his assistants, or any officer directed by him, in the investigation of crime and the apprehension and prosecution of persons charged with or suspected of the commission of crime, shall be paid by the respective counties, out of moneys in the county treasury, upon the approval of the bill of expense by the district attorney and the court of their respective counties. And in cases where a defendant is convicted and sentenced to pay the costs of prosecution and trial, the expenses of the district attorney, in connection with such prosecution, shall be considered a part of the costs of the cases and be paid by the defendant.
16 P.S. § 7708