在没有出现的情况下对程序进行修改

时间:2016-04-08 12:34:43

标签: c#

如何在VB.NET / C#中弹出一个DOS应用程序,它不会在屏幕上闪烁。我宁愿它不出现因为它闪烁,它打开然后在处理后终止。

1 个答案:

答案 0 :(得分:1)

我发现这个有用example。引用如下:

static void LaunchCommandLineApp()
{
    // For the example.
    const string ex1 = "C:\\";
    const string ex2 = "C:\\Dir";

    // Use ProcessStartInfo class.
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.CreateNoWindow = false;
    startInfo.UseShellExecute = false;
    startInfo.FileName = "dcm2jpg.exe";
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;

    try
    {
        // Start the process with the info we specified.
        // Call WaitForExit and then the using-statement will close.
        using (Process exeProcess = Process.Start(startInfo))
        {
            exeProcess.WaitForExit();
        }
    }
    catch
    {
        // Log error?
    }
}