winexec(pchar('cmd.exe /c netstat -n>netstat.txt'),sw_hide);
这样生成一文件netstat.txt, 我的程序在生成此文件3秒后读它, 但有时这文件还没写入磁盘, 出现打不开此文件的错误. 
如何能判断此文件写入磁盘后再打开它呢?

解决方案 »

  1.   

    你用WinExec比較難判斷, 最好用 CreateProcess 方式來運行程序!
      

  2.   

    // uses ShellAPI;winexec(pchar('cmd.exe /c netstat -n>netstat.txt'),sw_hide);
      if FileExists('netstat.txt') then
        ShellExecute(0, nil, PChar('netstat.txt'), nil, nil, SW_NORMAL);
      

  3.   

    to 杜克
       ShellExecute(0, nil, PChar('netstat.txt'), nil, nil, SW_NORMAL);
    是什么功能? 能避免文件写入一半被读出吗?
      

  4.   

    可以用SHELL控件,获取netstat.txt文件改变后进行反应