プロセスを起動してデータをstdinにプッシュする方法についていくつか質問がありますが、出力の行き先を制御する方法についてはわかりません。
まず、コンソールモードのC#アプリケーションから実行する現在のコードを次に示します。
// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
// Enter in the command line arguments, everything you would enter after the executable name itself
start.Arguments = " -";
// Enter the executable to run, including the complete path
start.FileName = "doxygen.exe";
// Do you want to show a console window?
start.WindowStyle = ProcessWindowStyle.Normal;
start.CreateNoWindow = false;
start.RedirectStandardInput = true;
start.UseShellExecute = false;
// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
//doxygenProperties is just a dictionary
foreach (string key in doxygenProperties.Keys)
proc.StandardInput.WriteLine(key+" = "+doxygenProperties[key]);
proc.StandardInput.Close();
proc.WaitForExit();
// Retrieve the app's exit code
int exitCode = proc.ExitCode;
}
これを実行すると、新しいウィンドウが表示されず(必要だと思いますが)、doxygen.exeのすべてのstdoutがアプリのコンソールウィンドウに出力されます。
私がしたいのは、次の2つのうちの1つです。
- Doxygenは表示されているウィンドウで起動され、アプリのウィンドウではなく、そのウィンドウでstdoutを確認できます。
- Doxygenは非表示のウィンドウで起動され、そのstdoutはログファイルに書き込まれます。
どうすればこれらを達成できますか?
さらに、スポーンされたプロセス用に別のウィンドウが表示されないのはなぜですか?また、スポーンされたプロセスが自分のウィンドウに出力を書き込んでいるのはなぜですか?