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中的free和nil

Delphi image 等比例缩小

Delphi 调用js脚本

Delphi 之 列表框组件(tlistbox)

tidhttpresponseinfo 中文乱码问题解决

Delphi从内存(memorystream)使用wmp

Delphi 判断素数的简单例子

Delphi 执行cmd并取得返回值

Delphi中轻松实现tidftp的断点续传

Delphi输入汉字自动产生拼音简码

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



打赏

取消

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

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

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

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

评论

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