[原创][求助] DELPHI 中如何使用TIdHTTP控间应用于图片调阅的问题
程序报错,出现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;
部分相关代码如下:
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;
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;
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;
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;
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;
请大家帮忙解决
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;
请大家帮忙解决