unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
StdCtrls, jpeg // Delphi 提示找不到这个单元文件,晕, GIFImage //这个单元要自己手动添加的,不自带, WinInet;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
// url = 'http://ptlogin2.qq.com/getimage?aid=15000701&0.9129723031485226';
url='http://www.0zer.cn/function/c_validcode.asp?name=loginvalid';
var
ms: TMemoryStream;
//jpg: TJPEGImage;
te: TGIFImage;
begin
ms := TMemoryStream.Create;
//jpg := TJPEGImage.Create;
te:=TGIFImage.Create;
if InternetGetConnectedState(nil,0) then //检测计算机是否联网需要引用WinInet
begin
IdHTTP1.Get(url, ms);
ms.Position := 0;
//jpg.LoadFromStream(ms);
te.LoadFromStream(ms);
Canvas.Draw(10, 10, te);
end
else
begin
ShowMessage('错误');
//jpg.Free;
te.Free;
ms.Free;
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
StdCtrls, jpeg // Delphi 提示找不到这个单元文件,晕, GIFImage //这个单元要自己手动添加的,不自带, WinInet;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
// url = 'http://ptlogin2.qq.com/getimage?aid=15000701&0.9129723031485226';
url='http://www.0zer.cn/function/c_validcode.asp?name=loginvalid';
var
ms: TMemoryStream;
//jpg: TJPEGImage;
te: TGIFImage;
begin
ms := TMemoryStream.Create;
//jpg := TJPEGImage.Create;
te:=TGIFImage.Create;
if InternetGetConnectedState(nil,0) then //检测计算机是否联网需要引用WinInet
begin
IdHTTP1.Get(url, ms);
ms.Position := 0;
//jpg.LoadFromStream(ms);
te.LoadFromStream(ms);
Canvas.Draw(10, 10, te);
end
else
begin
ShowMessage('错误');
//jpg.Free;
te.Free;
ms.Free;
end;
end;
end.