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 winsock远程唤醒计算机的函数

Delphi xe5-android开发 目录结构

Delphi application.title在win7下失效了?

Delphi使用idhttp模拟提交页面方法总结

Delphi Delphi tparallel cleanup needed用法

Delphi 检测一个网络连接是否有效带超时

Delphi整理八(对话框)

Delphi代码实现窗口最小化,最大化,关闭消息发送

Delphi使用sqlite数据库时的中文路径问题

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



打赏

取消

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

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

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

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

评论

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