All necessary expenses incurred by the district attorney 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 county from the general funds of the county, upon the approval of the bill of expenses by the district attorney and the court. In any case 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 case and be paid by the defendant.
16 P.S. § 4403