Delphi中的一个文件下载函数

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;

posted @ 2009-08-22 03:37  冷寒生  阅读(201)  评论(0编辑  收藏  举报
IT知识库