用这句    Reset(TF);
会出现下面错误,这是为什么!?---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EInOutError with message 'I/O error 32'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------

解决方案 »

  1.   


    //*************************************************
    //编译过程,编译成功返回TURE,编译失败返回FALSE.
    //filename:需编译的*.C文件,refilename:保存结果,保存CONSOLE 程序的输出,
    Function mycompile(filename,refilename:string;handle:Thandle):boolean;
    var s,s1:string;
        ch:char;
        i,j:integer;
        TF:TextFile;
    begin
    try
      DeleteFile(refilename);
      s:='/c C:\turboc2\tcc -exxx '+filename+'>'+refilename;
      i:=ShellExecute(handle, 'open', PChar('command.com'), PChar(s), nil, SW_hide);
      if i<= 32 then
        begin
        result:=false;   showmessage('1;');
        exit;
        end
      else
        begin
        j:=0;
        sleep(1);
        while  not FileExists(refilename) do
          begin
            sleep(50);
            j:=j+1;
            if j=20 then
              begin
              result := false;       showmessage('2;');
              exit;
              end;
          end;
        AssignFile(TF,refilename) ;
        Reset(TF);
        s1:='';
        while not Eof(TF) do
          begin
          read(TF,ch);
          s1:=s1+ch;
          end;
        closefile(TF);
        DeleteFile(refilename);
        if (pos('Error',s1)<>0) or (pos('not',s1)<>0) or (pos('error',s1)<>0) then
          begin
          result := false;    showmessage('3;');
          exit;
          end
        else
          begin
          result := true;
          exit;
          end;
        end;//end if i>32
    except
      result := false;     showmessage('4;');
      exit;
    end;
    end;
      

  2.   

    不好意思,昨天下线了
    你先检查一下你执行
    AssignFile(TF,refilename) ;
    Reset(TF);
    时文件有没有真正存在,如果存在的话
    由于你的文件是用重定向生成的,检查一下打开时,它有没有被关闭.还有,
        while  not FileExists(refilename) do
          begin
            sleep(50);
            j:=j+1;
            if j=20 then
              begin
              result := false;       showmessage('2;');
              exit;
              end;
          end;
    这段是用来延时的吧,时间够吗?
      

  3.   

    ---------------------------
    Debugger Exception Notification
    ---------------------------
    Project Project1.exe raised exception class EInOutError with message 'I/O error 32'. Process stopped. Use Step or Run to continue.
    ---------------------------
    OK   Help   
    ---------------------------该异常说明: 32 Sharing violation (共享错误)即是说还有其它程序打开了该文件没有关闭.可能是shellExecute产生该文件后没有关闭.
      

  4.   

    改成进程做了.可以搞定了.用CREATEPROCESS不过还有个问题..帮助看一下.谢谢先...

    var 
        SI: TStartupInfo;
        PI: TProcessInformation;

    begin
      FillChar(sI,sizeof(sI),#0);
      sI.cb := SizeOf(sI);      // CREATE_NEW_CONSOLE or
      si.dwFlags:=STARTF_USESTDHANDLES; //or STARTF_USESTDHANDLES
      SI.wShowWindow := SW_hide;  
      s:='cmd.exe /k C:\turboc2\tcc -exxx '+filename+'>'+refilename;
      //i:=ShellExecute(handle, 'open', PChar('command.com'), PChar(s), nil, SW_hide); --以前用这个DOS窗口不会显示出来.
      CreateProcess(nil,pchar(s),nil,nil,false,NORMAL_PRIORITY_CLASS, nil, nil, sI, pI) ;  --现在DOS窗口会显示出来.
    end;怎么使DOS窗口不显示出来,    SI.wShowWindow := SW_hide; 这样不行吗!?