- 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('\0', 256);
- if (GetImageFromBuffer(bs, bs.Length, result))
- {
- vCode = result.ToString();
- }
- else
- {
- vCode = "识别失败!";
- }
- }
- return vCode;
- }
- }
验证码
来源: http://www.bubuko.com/infodetail-2663630.html