一个delphi窗体form1 
上面有一个edit1控件 
两个Button1 
一个是启动 
一个是关闭 要求,当按下启动时 
就会执行目录下的a.bat 
并把结果实时返回到edit1中 当按下关闭时,强行结束a.bat执行过程同步显示在edit1里

解决方案 »

  1.   

    使用ShellExecute,执行 a.bat > tmp.txt, 然后取出tmp.txt于edit1中, 再删除tmp.txt
      

  2.   

    TDosCommand控件可以实时返回DOS命令的输出:
    http://maxxdelphisite.free.fr/doscmd.htm
      

  3.   

    可以用 Lysee到 www.lysee.net 下载安装程序安装后,将 lseu.pas 和 lysee.dll 拷贝到你的程序目录,
    将 lseu.pas 加入到工程中。执行外部程序并获得输出用下面这个函数就行了:function shouts(const S: string)
    {
      with TLseEngine.Create(nil) do
      try
        if not ExecuteCode('return `' + S + '`') then
          raise Exception.Create(Error);
        Result := ResultText;
      finally
        Free;
      end;
    }// sample
    string s = shouts('aaa.bat');