Воскресенье, 19.05.2024, 16:49
Приветствую Вас Гость | RSS
delphicode.clan.su
Форма входа
Поиск
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
 
 СКАЧАТЬ ФАЙЛ ИЗ ИНТЕРНЕТА
  
 В 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://imgl.yandex.net/i/www/logo.png';
 // Where to save the file
 DestFile = 'c:\logo.png';
 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;