【发布时间】:2016-04-08 12:34:42
【问题描述】:
我怎样才能在 VB.NET/C# 中打开一个 DOS 应用程序并且它不会在屏幕上闪烁。我宁愿它不会出现,因为它会闪烁,它会打开,然后在完成处理后终止。
【问题讨论】:
标签: c#
我怎样才能在 VB.NET/C# 中打开一个 DOS 应用程序并且它不会在屏幕上闪烁。我宁愿它不会出现,因为它会闪烁,它会打开,然后在完成处理后终止。
【问题讨论】:
标签: c#
我发现这很有用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?
}
}
【讨论】:
startInfo.CreateNoWindow = false; 是true?
ProcessWindowStyle.Hidden; 做了同样的事情。某些应用程序可能希望某个窗口存在于某处……我建议您操作这些设置,直到它以您希望的确切方式工作。我的回答只是为了提供一种访问流程设置的方法。