7th
Май

Как скачать файл?

Posted by Chas under Пост-обзор

Alex2009:

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
SourceFile = ‘http://rap-zt.at.ua/style/photo/cover2/mafon.jpg’;
DestFile = ‘c:\temp\mafon.jpg’;
begin
   if DownloadFile(SourceFile, DestFile) then
   begin
     ShowMessage(’Файл скачанl!’);
     ShellExecute(Application.Handle, PChar(’open’), PChar(DestFile),
       PChar(”), nil, SW_NORMAL)
   end
   else
     ShowMessage(’Ошибка закачки ‘ + SourceFile)
end;

Перейти к обсуждению на форуме

Похожие статьи