public class VerificationCode { [DllImport("WmCode.dll")] public static extern bool LoadWmFromFile(string FilePath, string Password); [DllImport("WmCode.dll")] public static extern bool SetWmOption(int OptionIndex, int OptionValue); [DllImport("WmCode.dll")] public static extern bool GetImageFromBuffer(byte[] FileBuffer, int ImgBufLen, StringBuilder Vcode); public static string GetVerCode(byte[] bs) { string vCode = string.Empty; string path = AppDomain.CurrentDomain.BaseDirectory + "bin\YongAn.dat"; if (LoadWmFromFile(path, "123456")) { //SetWmOption(6, 90); StringBuilder result = new StringBuilder(' ', 256); if (GetImageFromBuffer(bs, bs.Length, result)) { vCode = result.ToString(); } else { vCode = "识别失败!"; } } return vCode; } }