All necessary expenses incurred by the district attorney or the district attorney's assistants or any officer directed by the district attorney in the investigation of crime and the apprehension and prosecution of persons charged with or suspected of the commission of crime, upon approval thereof by the district attorney and the court, shall be paid by the county from the general funds of the county. 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. § 1403