1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
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
SourceFile = 'http://nahwah.ifrance.com/Gescom/QualiServ.exe';
// Répertoire de destination du fichier
DestFile = 'c:\Qualiserv.exe';
begin
if DownloadFile(SourceFile, DestFile) then
begin
ShowMessage('Download succesful!');
// Afficher l'image dans le navigateur
ShellExecute(Application.Handle, PChar('open'), PChar(DestFile), PChar(''), nil, SW_NORMAL)
end
else
ShowMessage('Error while downloading ' + SourceFile)
end; |
Partager