这种验证码如何识别?(100)

  • 主题发起人 主题发起人 juemimima11
  • 开始时间 开始时间
J

juemimima11

Unregistered / Unconfirmed
GUEST, unregistred user!
这种验证码如何识别?
1.bmp
这种验证码如何识别请给出源码,谢谢
 
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, SHDocVw, StdCtrls, ExtCtrls, ImgList, Math;type TForm1 = class(TForm) WebBrowser1: TWebBrowser; Button1: TButton; Button2: TButton; Image1: TImage; Edit1: TEdit; ImageList1: TImageList; Image2: TImage; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public function GetNum:string; end; const URL = 'http://www.baidu.com';var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin WebBrowser1.Navigate(URL);end;procedure TForm1.Button1Click(Sender: TObject);begin WebBrowser1.Navigate(URL); WebBrowser1.Refresh;end;function SameCanvas(mCanvasA, mCanvasB: TCanvas): Boolean; { 比较两个画布是否相同 }var I, J: Integer;begin Result := False; if not Assigned(mCanvasA) then Exit; if not Assigned(mCanvasB) then Exit; for I := Min(mCanvasA.ClipRect.Left, mCanvasB.ClipRect.Left) to Min(mCanvasA.ClipRect.Right, mCanvasB.ClipRect.Right) do for J := Min(mCanvasA.ClipRect.Top, mCanvasB.ClipRect.Top) to Min(mCanvasA.ClipRect.Bottom, mCanvasB.ClipRect.Bottom) do if mCanvasA.Pixels[I, J] <> mCanvasB.Pixels[I, J] then Exit; Result := True;end; { SameCanvas }function TForm1.GetNum:string;var Dc:Hdc; BitMap,NumBitMap:TBitMap; i,l:integer;begin Result := ''; BitMap := TBitMap.Create; BitMap.Width := 9; BitMap.Height := 15; NumBitMap := TBitMap.Create; NumBitMap.Width := 9; NumBitMap.Height := 15; DC := GetDC(WebBrowser1.Handle); //Image1.Picture.Bitmap.Width:=9; //Image1.Picture.Bitmap.Height:=15; //Image2.Picture.Bitmap.Width:=9; //Image2.Picture.Bitmap.Height:=15; try for i := 0 to 3 do begin BitBlt(Bitmap.Canvas.Handle, 0, 0, 9, 15, DC, 19 + i * 9 + i * 2, 22, SRCCOPY); Bitmap.PixelFormat := pf1bit; //Image1.Picture.Assign(Bitmap); for l := 0 to 9 do begin NumBitMap.Canvas.FillRect(NumBitMap.Canvas.ClipRect); ImageList1.Draw(NumBitMap.Canvas,0,0,l); //Image2.Picture.Assign(NumBitmap); NumBitmap.PixelFormat := pf1bit; if SameCanvas(Bitmap.Canvas, NumBitmap.Canvas) then begin Result := Result + IntToStr(l); Break; end; end; end; finally DeleteDC(DC); BitMap.Free; NumBitMap.Free; end;end;procedure TForm1.Button2Click(Sender: TObject);begin Edit1.Text := '2'; Edit1.Text := GetNum;end;end.
 
后退
顶部