C#调用亦思DLL识别验证码备份
下面是关于C#调用亦思DLL来识别验证码的方法的,需要亦思破解版的可以加群:37140394,找群主要。这里是自己从易语言的调用方法中修改过来的,有2种识别方式,第一种保存到本地识别,第二种直接在内存中识别。
保存到本地识别的方法
- public static void Recognition(ref string jieguo, string url, string locatepic, ref string resultpic)
- {
- try
- {
- int i = 0;
- int n2 = 0;
- IntPtr n1 = new IntPtr();
- IntPtr no1 = Recognition(1, null, 0, url, locatepic, ref n1, ref n2, ref i);
- jieguo = Marshal.PtrToStringAnsi(no1);
- // Writepic(""); //这行代码的目的是把图片解码成bmp图片,可选。
- // resultpic = @"c:\code.bmp"; //默认存放到c:\code.bmp
- }
- catch (System.Exception ex)
- {
- }
- }
验证码图片保存到本地识别
- imageStream = System.Drawing.Image.FromStream(TianCiClass.GetHttpImageByGet(codeurl, cookie));
- result = "";
- imglocation = "";
- imageStream.Save("code.bmp");
- // Thread.Sleep(AddFriendDelyTime * 1000);
- TianCiClass.Recognition(ref result, "", "code.bmp", ref imglocation);
- code = result;
下面记录下朋友告诉我的直接内存识别
Code
- public static void Recognition(ref string jieguo, byte[] pic, int bytepic, string locatepic)
- {
- try
- {
- int cLength = 0;
- int lpLength = 0;
- IntPtr lppicout = new IntPtr();
- IntPtr ptr = Recognition(1, pic, bytepic, null, locatepic, ref lppicout, ref lpLength, ref cLength);
- jieguo = Marshal.PtrToStringAnsi(ptr);
- }
- catch (Exception)
- {
- }
- }
Code
- Image imageStream = System.Drawing.Image.FromStream(TianCiClass.GetHttpImageByGet(codeurl, cookie));
- MemoryStream ms = new MemoryStream();
- byte[] imagedata = null;
- imageStream.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
- imagedata = ms.GetBuffer();
- string result = "";
- string imglocation = "";
- // imageStream.Save("pic_.bmp");
- // TianCiClass.Recognition(ref result, "", "pic_.bmp", ref imglocation);
- TianCiClass.Recognition(ref result, imagedata, imagedata.Length, imglocation);
- // pictureBox1.ImageLocation = imglocation;
- // textBox1.Text = result;
- string code = result;
Popularity: 20% [?]
最新评论