If any proceeding for an offense, had or moved at the instance of a prosecutor, be dismissed, or the accused discharged from the accusation, the court or justice before whom the proceeding is may give judgment against the prosecutor in favor of the accused for his costs.
W. Va. Code § 62-2-3