2

私は自分のプロジェクトの1つでトランスコーディングにlameを使用しています。問題は、C#からlameを呼び出すと、DOSウィンドウがポップアップすることです。これを抑える方法はありますか?

これまでの私のコードは次のとおりです。

Process converter =
    Process.Start(lameExePath, "-V2 \"" + waveFile + "\" \"" + mp3File + "\"");

converter.WaitForExit();
4

4 に答える 4

8

次のようなことを試しましたか?

using( var process = new Process() )
{
    process.StartInfo.FileName = "...";
    process.StartInfo.WorkingDirectory = "...";
    process.StartInfo.CreateNoWindow = true;
    process.StartInfo.UseShellExecute = false;
    process.Start();
}
于 2010-03-30T14:39:54.470 に答える
3

を介して呼び出していると仮定すると、プロパティがに設定され、に設定されてProcess.Startいるオーバーロードを使用できます。ProcessStartInfoCreateNoWindowtrueUseShellExecutefalse

ProcessStartInfoオブジェクトにはプロパティを介してアクセスすることもでき、Process.StartInfoプロセスを開始する直前にそこに設定できます(セットアップするプロパティの数が少ない場合は簡単です)。

于 2010-03-30T14:40:18.927 に答える
3
Process bhd = new Process(); 
bhd.StartInfo.FileName = "NSOMod.exe";
bhd.StartInfo.Arguments = "/mod NSOmod /d";
bhd.StartInfo.CreateNoWindow = true;
bhd.StartInfo.UseShellExecute = false;

別の方法です。

于 2010-03-30T14:40:38.177 に答える
2

これは、同様のことを行う私のコードです(また、出力コードと戻りコードを読み取ります)

        process.StartInfo.FileName = toolFilePath; 
        process.StartInfo.Arguments = parameters; 

        process.StartInfo.UseShellExecute = false; // needs to be false in order to redirect output 
        process.StartInfo.RedirectStandardOutput = true; 
        process.StartInfo.RedirectStandardError = true; 
        process.StartInfo.RedirectStandardInput = true; // redirect all 3, as it should be all 3 or none 
        process.StartInfo.WorkingDirectory = Path.GetDirectoryName(toolFilePath); 

        process.StartInfo.Domain = domain; 
        process.StartInfo.UserName = userName; 
        process.StartInfo.Password = decryptedPassword; 

        process.Start(); 

        output = process.StandardOutput.ReadToEnd(); // read the output here... 

        process.WaitForExit(); // ...then wait for exit, as after exit, it can't read the output 

        returnCode = process.ExitCode; 

        process.Close(); // once we have read the exit code, can close the process 
于 2010-03-30T15:18:39.007 に答える