Uses URLMon, ShellApi; function DownloadFile(SourceFile, DestFile: string): Boolean; begin try Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0; except Result := False; end; end; procedure TForm1.Button1Click(Sender: TObject); const // URL Location SourceFile = 'http://www.google.com/intl/de/images/home_title.gif'; // Where to save the file DestFile = 'c:\temp\google-image.gif'; begin if DownloadFile (SourceFile, DestFile) then begin ShowMessage('Download succesful!'); // Show downloaded image in your browser ShellExecute(Application.Handle,PChar('open'),PChar(DestFile),PChar(''),nil,SW_NORMAL) end else ShowMessage('Error while downloading ' + SourceFile) end;
1:FTP只能连接FTP服务器. 2:URLMon是什么?谢谢关注
和和,你查找一下urlmon保证你能找到:)
to sundayboys(sunboy): 很好用,多谢。问如果不下载到文件,而是读到数据流里,有没有直接的函数?(主要是想加快点速度) 不管怎样马上给分。
begin
try
Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
except
Result := False;
end;
end; procedure TForm1.Button1Click(Sender: TObject);
const
// URL Location
SourceFile = 'http://www.google.com/intl/de/images/home_title.gif';
// Where to save the file
DestFile = 'c:\temp\google-image.gif';
begin
if DownloadFile (SourceFile, DestFile) then
begin
ShowMessage('Download succesful!');
// Show downloaded image in your browser
ShellExecute(Application.Handle,PChar('open'),PChar(DestFile),PChar(''),nil,SW_NORMAL)
end
else
ShowMessage('Error while downloading ' + SourceFile)
end;
2:URLMon是什么?谢谢关注
很好用,多谢。问如果不下载到文件,而是读到数据流里,有没有直接的函数?(主要是想加快点速度)
不管怎样马上给分。