注册 登录
编程论坛 Delphi论坛

[原创][求助] DELPHI 中如何使用TIdHTTP控间应用于图片调阅的问题

ecust_haibo 发布于 2007-04-12 20:15, 1007 次点击
程序报错,出现Access violation at address 00403FD4 in module 'XXXX.EXE'. Read of address FFFFFFFF.

部分相关代码如下:

procedure TfrmOutListPicShow.FormShow(Sender: TObject);
var
str1,str2,ctype1,sINISYSMANAGER: String;
LStream1: TMemoryStream;
strStream1: TStringStream;
img1,img2: TGraphic;
begin
str1:= 'http://192.168.0.71:8800/inlistread.jsp?AreaNo=3401&RoadNo=12&SubRoadNo=14&StationNo=1201&LaneNo=15&CardNo=888&OpTime=2006-03-05%2011:11:11&VehPlate=888&Reqtype=1&reqsource=0';

try
try
LStream1 := TMemoryStream.Create;
strStream1 := TStringStream.Create('');
try
IdHttp1.Get(str1, LStream1);
except
on E: Exception do
ShowMessage('图像调阅服务没有启动或连接超时,无法查看图片!');
end;
ctype1:=IdHttp1.Response.ContentType;
if ( ctype1='image/jpg') or ( ctype1='image/jpeg') then
img1 := TJPEGImage.Create
else if ctype1='image/bmp' then
img1 := TBitmap.Create
else if ctype1='text/html' then
begin
LStream1.SaveToStream(strStream1);
Abort ;
end
else Abort ;

if LStream1.Size=0 then
begin
ShowMessage('没有找到对应的图片!');
Abort ;
end;
LStream1.Position := 0;
img1.LoadFromStream(LStream1);
imgInList.Picture.Assign(img1);
except
end ;
finally
if LStream1 <> nil then LStream1.Free;
if strStream1 <> nil then strStream1.Free;
if img1 <> nil then img1.Free;
end;
try
try
LStream1 := TMemoryStream.Create;
strStream1 := TStringStream.Create('');
try
IdHttp1.Get(str2, LStream1);
except
on E: Exception do
ShowMessage('图像调阅服务没有启动或连接超时,无法查看图片!');
end;
ctype1:=IdHttp1.Response.ContentType;
if ( ctype1='image/jpg') or ( ctype1='image/jpeg') then
img1 := TJPEGImage.Create
else if ctype1='image/bmp' then
img1 := TBitmap.Create
else if ctype1='text/html' then
begin
LStream1.SaveToStream(strStream1);
Abort ;
end
else Abort ;

if LStream1.Size=0 then
begin
ShowMessage('没有找到对应的图片!');
Abort ;
end;
LStream1.Position := 0;
img1.LoadFromStream(LStream1);
imgOutList.Picture.Assign(img1);
except
end ;
finally
if LStream1 <> nil then LStream1.Free;
if strStream1 <> nil then strStream1.Free;
if img1 <> nil then img1.Free;
end;
end;


请大家帮忙解决
5 回复
#2
ecust_haibo2007-04-12 20:52

自己先给自己顶一下的

#3
ecust_haibo2007-04-13 08:49
继续顶一个,大家快来帮忙啊
#4
nongen2007-04-13 08:59
错误停在哪一行?
#5
ecust_haibo2007-04-13 10:00

调试的时候到 IdHttp1.Get(str2, LStream1);就会报错

#6
nongen2007-04-13 21:00
try
IdHttp1.Get(str2, LStream1);
except
on E: Exception do
ShowMessage('图像调阅服务没有启动或连接超时,无法查看图片!');
end;
你已经设置了try..except 那出错就是你所设置的了。图像调阅服务没有启动或连接超时,无法查看图片
编译完成的,直接运行的exe文件,会在这里显示你所设置的错误信息。而不是如你开头的提示错误。
1