验证码

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;
        }
    }

  

posted @ 2018-06-29 09:16  会弹猫的吉他  阅读(221)  评论(0编辑  收藏  举报