网络传送简单问题,接收端死掉,如何释放! 是不是try没有用好(200)

  • 主题发起人 主题发起人 laowt
  • 开始时间 开始时间
L

laowt

Unregistered / Unconfirmed
GUEST, unregistred user!
这是盒子下的一段代码,网络传送接收端出现问题(死掉),设置跟踪(label4.Caption)没发现问题!结果label4.Caption显示都是“eee”,程序照样死掉(就是Button1不能再用),请教:1、问题会在那一句?2、用什么办法当死掉时,将该段释放,使Button1还能用(继续最新发送)原代码如下:procedure TForm2.Button1Click(Sender: TObject);var Request: TRequest; ResponseBlock: TResponseBlock; FileInfo : TInfo; FS : TFileStream; I,shij : Integer;begin label4.Caption:='000'; ZeroMemory(@Request,SizeOf(Request)); label4.Caption:='111'; ZeroMemory(@ResponseBlock,SizeOf(ResponseBlock)); label4.Caption:='222'; ZeroMemory(@FileInfo,SizeOf(FileInfo)); label4.Caption:='333'; StrCopy(Request.Info.FileName,PChar('D://trys/test.jpg')); label4.Caption:='444'; Request.RequestType := RT_Info; label4.Caption:='555'; IdUDPCpic.BufferSize := 8192; label4.Caption:='666'; IdUDPCpic.SendBuffer('ys0000.51vip.biz',9999,Request,SizeOf(Request)); label4.Caption:='777'; IdUDPCpic.ReceiveBuffer(FileInfo,SizeOf(FileInfo)); label4.Caption:='888'; Self.redtmmo2.Lines.Add('文件:'+FileInfo.FileName); Self.redtmmo2.Lines.Add('大小:'+IntToStr(FileInfo.Size)); Self.redtmmo2.Lines.Add('块数:'+IntToStr(FileInfo.BlockCount)); label4.Caption:='999'; FS := TFileStream.Create('D://trys/test.jpg',fmCreate); label4.Caption:='000'; try shij:=cis; Request.Info := FileInfo; Request.RequestType := RT_Block; Self.ProgressBar1.Position := 0; Self.ProgressBar1.Max := FileInfo.BlockCount; Self.ProgressBar1.Step := 1; for i:=1 to FileInfo.BlockCount do begin label4.Caption:=''; if cis-shij>0 then exit; Request.Info.BlockPostion := i; label4.Caption:='aaa'; IdUDPCpic.SendBuffer('ys0000.51vip.biz',9999,Request,SizeOf(Request)); label4.Caption:='bbb'; IdUDPCpic.ReceiveBuffer(ResponseBlock,SizeOf(ResponseBlock)); label4.Caption:='ccc'; FS.Write(ResponseBlock.Block.Data,ResponseBlock.Block.DataSize); label4.Caption:='ddd'; Self.ProgressBar1.StepIt; label4.Caption:='eee'; {if i=FileInfo.BlockCount-1 then begin timer1.Enabled:=true; label2.Caption:='tupian'; end; } end; Self.ProgressBar1.Position := 0; finally FS.Free; //inc(shib); //label3.Caption:='失败'+inttostr(shib)+'次'; end; {ZnZip1.SourceFile := 'D:/trys/test1.bmp'; ZnZip1.DestFile := 'D:/trys/test2.bmp'; ZnZip1.UnZipFile; } Image1.Picture.LoadFromFile('D:/trys/test.jpg');end;
 
是不是try没有用好
 
后退
顶部