.NET获取其它程序的标准输出(stdout)

创建进程的时候,把ProcessStartInfo 的RedirectStandardOutput 设为true

UseShellExecute 设为false

如果让创建的进程不可见,把CreateNoWindow 设为true

   ProcessStartInfo psi = new ProcessStartInfo();
   psi.FileName = “<<exe file name>>“;
   psi.UseShellExecute = false;
   psi.CreateNoWindow = true;
   psi.RedirectStandardOutput = true;

   Process p = Process.Start(psi);
   while(p.WaitForExit(0) == false)
   {
    String s = p.StandardOutput.ReadLine();
   }

这样你就可以获得你所创建的进程调用Console.Write的输出

posted @ 2004-08-14 12:10  Alvin  阅读(746)  评论(0)    收藏  举报