2011-05-15 187 views
1

可能重複:
Downloading a file in Delphi
Delphi File Downloader Component獲取網頁

大家好, 我試圖開發一個Delphi 7應用程序,它可作爲一種貨幣數據庫或者接近它的東西(不要問我爲什麼,我只是爲了賺錢:))。因此當前的任務是從服務器下載包含貨幣列表的網頁並將該列表提取到數據庫。 是否有可能以及需要使用哪些工具來加以解決?我知道PHP,但PHP編寫GUI似乎一些瘋狂)

+0

http://stackoverflow.com/questions/3506251/downloading-a-file-in-delphi,http://stackoverflow.com/questions/4521535/delphi-file-downloader-component,等等 – 2011-05-15 10:32:09

回答

2

爲了增加安德烈亞斯評論,你還可以檢查出Delphi.About.com,有一個例子那裏下載一個文件,並顯示一個進度:http://delphi.about.com/cs/adptips2003/a/bltip0903_2.htm

「如果您需要將指定URL的內容保存到文件中並且能夠跟蹤下載進度,請使用TDownLoadURL Delphi動作 TDownLoadURL正在寫入指定文件時,它會定期生成一個OnDownloadProgress事件,以便您可以向用戶提供關於該過程的反饋。 下面是一個示例 - 請注意,您必須在使用條款中包含單元ExtActns。「

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;