delphi webbrowser 获取验证码

来源:互联网 发布:iap 元数据丢失 编辑:程序博客网 时间:2024/05/17 06:02

use

clipbrd , mshtml


procedure TForm1.DomImg2Image(src:string;wb:TWebBrowser;img:TImage);

var
  i:Integer;
  rang:IHTMLControlRange;
begin
  for i:=0 to IHTMLDocument2(wb.Document).images.length-1 do
    if Pos(src,(IHTMLDocument2(wb.Document).images.item(i,EmptyParam)as
      IHTMLElement).getAttribute('src',0))>0 then
    begin
      rang:=((IHTMLDocument2(wb.Document).body as HTMLBody).createControlRange)as
        IHTMLControlRange;
      rang.add(IHTMLDocument2(wb.Document).images.item(i,EmptyParam)as
        IHTMLControlElement);
      rang.execCommand('Copy',False,0);
      try img.Picture.Assign(ClipBoard)except end;
      break;
    end;

end;


DomImg2Image('CheckCode?',wb1,img1);

0 0