unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtCtrls, IdHTTP, jpeg;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure Button1Click(Sender: TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var WebBrowser1:TWebBrowser;
Image1: TImage;
procedure TForm1.Button1Click(Sender: TObject);
const URL= 'http://218.205.192.16';
var s:string;
pic:TJPEGImage;
ms:TMemoryStream;
IdHTTP:TIdHTTP;
begin
WebBrowser1.Navigate(URL);
while webbrowser1.ReadyState <>READYSTATE_COMPLETE do
Application.ProcessMessages;
s:=WebBrowser1.OleObject.Document.parentWindow.form1.checkCodeTemp.value;
if s='' then exit;
Canvas.TextOut(450,200,'验证码: '+s);
//以下显示图片:
IdHTTP:=TIdHTTP.Create(self);
try
ms:=TMemoryStream.Create;
try
IdHTTP.Get(URL+'/ucas/user/pasmCheckCode.htm?rand='+s, ms);
ms.Position:=0;
pic:=TJPEGImage.Create;
try
pic.LoadFromStream(ms);
Image1.Picture.Assign(pic);
finally
pic.Free;
end;
finally
ms.Free;
end;
finally
IdHTTP.Free;
end;
end;
end.