|
QUESTION: How do I download a file from a URL location? ANSWER: There are a number of ways to do this, below is a simple code snippit that will give you an idea of how to do this. Make sure to add ShellApi, and UrlMon to your uses clause.
function DownLoadInternetFile(Source, Dest : String): Boolean;
begin
try
Result := URLDownloadToFile(nil,PChar(Source),PChar(Dest),0,nil) = 0
except
Result := False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
SourceString, DestinationString: string;
begin
//File location on the Internet.
SourceString := 'http://www.borland.com/images/homepage/del6homemural.gif';
//File destination.
DestinationString := 'C:Tempdel6homemural.gif';
if DownLoadInternetFile(SourceString, DestinationString) then
//This will display the file from your browser.
ShellExecute(Application.Handle, PChar('Open'), PChar(DestinationString), PChar(''), nil, SW_NORMAL)
else
ShowMessage('Error during Download ' + SourceString);
end;
|
Last Modified: 31-AUG-01