20-04-2014, 11:45 PM
هدا الكود غير فعال نوعا ما يعني جربته ملف بي دي ف لكن لا يحمل
هدا كود اخر لكن لم اعرف كيف انفده
انا لم يصلح معي ولا واحد
ممكن واحد يتحفنا ببرنامج بالكود سورس
هدا كود اخر لكن لم اعرف كيف انفده
كود :
Download a file from the Internet with progress indicator
uses ExtActns, ...
type
TfrMain = class(TForm)
...
private
procedure URL_OnDownloadProgress
(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean) ;
...
implementation
...
procedure TfrMain.URL_OnDownloadProgress;
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
end;
function DoDownload;
begin
with TDownloadURL.Create(self) do
try
URL:='http://0.tqn.com/6/g/delphi/b/index.xml';
FileName := 'c:\ADPHealines.xml';
OnDownloadProgress := URL_OnDownloadProgress;
ExecuteTarget(nil) ;
finally
Free;
end;
end;
{
Note:
URL property points to Internet
FileName is the local file
/CODE]
وهذا بالاندي
Download file using Indy HTTP.pas
[CODE]
begin
windows.setFileAttributes(pFileName,NONE);//clear file attributes
result:=windows.deleteFile(pFileName); //then delete the file
end;
function downloadFile(pUrl,pFileName:pChar):boolean;
var fs:TFileStream;
begin
result:=false;
if (pUrl=nil) or (pFileName=nil) then exit; //Check arguments
if fileAge(pFileName)>-1 then forceDeleteFile(pFileName); //Delete existing file
try fs:=TFileStream.Create(pFileName,fmCreate) except exit end; //Create file stream
with TIdHttp.Create(nil) do begin //Create http object
request.userAgent:=INET_USERAGENT; //Define user agent
redirectMaximum:=INET_REDIRECT_MAX; //Redirect maxumum
handleRedirects:=INET_REDIRECT_MAX<>NONE; //Handle redirects
try get(pUrl,fs);result:=fs.size>NONE except end; //Do the request
free //Free the http object
end;fs.free; //Free the file stream
end;
//..
function boolToStr(bl:boolean):ansiString;
begin
if bl then result:='yes' else result:='no';
end;
procedure TForm1.FormCreate(Sender: TObject);
var aUrl,aFileName:ansiString;
begin
aUrl := 'http://www.mortenbs.com/music/qual4.gif';
aFileName := 'C:\qual4.gif';
caption:=boolToStr(downloadFile(pAnsiChar(aUrl),pAnsiChar(aFileName)));
end;انا لم يصلح معي ولا واحد
ممكن واحد يتحفنا ببرنامج بالكود سورس

