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;
本文介绍了一个简单的文件下载函数实现方法,使用UrlDownloadToFile函数从指定URL下载文件到本地路径,并通过一个示例展示了如何调用该函数。
1102

被折叠的 条评论
为什么被折叠?



