Delphi 获取网站验证码的图片

uses
  ActiveX,ComObj;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
  OleInitialize(nil);
end;

procedure TfrmMain.DomImg2Image(wb:TWebBrowser);
var
  i:Integer;
  rang:IHTMLControlRange;
  s:string;
begin
  try
  //pic是图片的节点(层)名称,你打开源代码看一下,替换成你的就行了
  s := (IHTMLDocument2(wb.Document).images.item('pic',EmptyParam) as IHTMLElement).getAttribute('src',0);
  //showmessage(s);
      rang:=((IHTMLDocument2(wb.Document).body as HTMLBody).createControlRange)as
        IHTMLControlRange;
      rang.add(IHTMLDocument2(wb.Document).images.item('pic',EmptyParam)as
        IHTMLControlElement);
      rang.execCommand('Copy',False,0);
      image1.Picture.Assign(ClipBoard);
  except
  end;
end;

procedure TfrmMain.FormDestroy(Sender: TObject);
begin
  OleUninitialize;
end;

你可能感兴趣的:(image,Integer,Delphi)