---------------------------
Debugger Exception Notification
---------------------------
Project LF961.exe raised exception class EPrivilege with message 'Privileged instruction'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------
function TRecordStream.AppendRec(Const Rec): Longint;
begin
  // This function writes the record Rec to the stream
  Seek(0, 2);//这里错误,错误如上面
  Result := Write(Rec, GetRecSize);
end;我在把数据读入到流文件时,发生的,为什么呢,我的流文件如下
    TPersonRec = packed record
    id:integer;
    Gps:string[23];
    multi:array[0..1008] of char;

解决方案 »

  1.   

    我的保存调用如下
    procedure tmain_form.put_lf961(id:integer;gp_str:string;lf_str:string;lf_bz:integer;gps_bol:boolean);
    var
      str:string;
      i,j,k:integer;
    begin
      try
      if length(lf_str)>17 then
      begin
        str:='';
        lf_record.id:=id;    if gps_bol=true then lf_record.Gps:=gp_str;
        if length(lf_str)<1009 then  strcopy(lf_record.Multi, PChar(lf_str))
        else
        strcopy(lf_record.Multi, PChar(copy(lf_str,1,1008)));       lf_stream.AppendRec(lf_record);
        lf_stream.NextRec;
      end;
      except on e:exception do
      begin
        showmessage(e.message);
        exit;
      end;
      end;
    end;
      

  2.   

    对不起各位大侠,是我搞错了,我流创建后有FREE了,没有在创建,
    所以出错,还有个问题请教,简单,我马上给分,如何判断一个文件流是否存在,
    我关闭窗口时需要用到
      if lf_stream<>nil then lf_stream.Free; 好象不对,请指点除了NIL还有什么办法,谢谢
      

  3.   

    lf_stream.Free
    lf_stream :=nil
      

  4.   

    放在finally里
    if lf_stream<>nil then 
    begin
      lf_stream.Free
      lf_stream :=nil
    end;
      

  5.   

    if lf_stream<>nil then lf_stream.Free 没有意义,Free方法实现本就是先判空再调destroy方法。要判断文件流是否存在好像没有太好的方法,象楼上说的,养成好习惯,对象释放后及时赋值nil
      

  6.   

    谢谢,我的意思是如何判断LF_STREAM 是否存在,因为如果没有存在我 lf_stream.Free
    lf_stream :=nil
    会报错,谢谢,