Delphi中的一个文件下载函数

来源:互联网 发布:思途cms旅游 价格 编辑:程序博客网 时间:2024/05/15 03:20

function DownloadFile(Source, Dest: string): Boolean;
begin
    try
        Result := UrlDownloadToFile(nil, PChar(source), PChar(Dest), 0, nil) = 0;
    except
        Result := False;
    end;
end;


procedure TForm1.btn2Click(Sender: TObject);
var
    SourceFile,DestFile:string;
begin
    SourceFile := 'http://www.baidu.com/';
    DestFile := 'c:/12ab.htm';
    DownloadFile(SourceFile, DestFile);
end;

原创粉丝点击