Delphi IdHTTP控件学习(图片下载)


本文整理自网络,侵删。

 unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;


type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var s:TStringList;
MStream:TMemoryStream;
i:integer;

begin
s:=TStringList.Create;
s.Add('http://www.3464.com/pic/bimg/albums/photos/1/0/1/101705/1139753842.jpg');
s.Add('http://www.delphitop.com/pic/bimg/albums/photos/1/0/1/101705/1139753793.jpg');
s.Add('http://www.j7j8.com/pic/bimg/albums/photos/1/0/1/101705/1139753782.jpg');
for i:=0 to s.Count-1 do
begin
MStream:=TMemoryStream.Create;
IdHttp1.Get(s[i],MStream);
MStream.SaveToFile('c:\'+IntToStr(i)+'.jpg');
MStream.Free;
end;
ShowMessage('下载完毕');
s.Free;
end;
end.

IdHTTP的创建
{IdHTTP := TIdHTTP.Create(nil);
try
IdHTTP.Get(URL, SavedStream);
finally
IdHTTP.Free;
end;}

相关阅读 >>

Delphi 屏蔽汉字,年月日,时间,银行卡正则表达式

Delphi 无法结束进程的程序

Delphi 字符串插入与删除

Delphi 提取网页源文件纯文本函数

Delphi datetime,date,time tdatetimepicker

Delphi 中文姓名 合法性检查

Delphi savetextfiledialog 用法

Delphi 汉字与区位码

Delphi 右下角滑动消息窗口

Delphi 设置打印机 纸张大小! 也可以获取纸张大小

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...