我的問題與other question I have asked about loading image from the URL有關。下面的代碼工作。 但是,如果我嘗試獲取圖像(它假設存在),但我已遇到問題,但顯然已刪除 。應用程序不知道並返回錯誤。 有沒有辦法通過捕獲傳入的錯誤來防止它。 我將不勝感激任何建議。 它發生在他行:從URL加載圖像 - 如果圖像不存在,如何捕獲異常
IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS);
謝謝, 克里斯
uses
GIFImg;
procedure TForm1.btn1Click(Sender: TObject);
var
MS : TMemoryStream;
GIf: TGIFImage;
begin
MS := TMemoryStream.Create;
GIf := TGIFImage.Create;
try
IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS);
Ms.Seek(0,soFromBeginning);
Gif.LoadFromStream(MS);
img1.Picture.Assign(GIF);
finally
FreeAndNil(GIF);
FreeAndNil(MS);
end;
end;
謝謝羅布, 我不知道如何申請除了和你的例子解決了我的問題。 我真的很感激。 Chris – Greener 2009-09-25 15:27:59