通常情况下,在命令提示符中调用Windows应用程序不会等待其退出。一旦我键入
我知道使用
任何建议都将不胜感激。谢谢!
myFormApp.exe
并按下回车键,一个表单将显示出来,命令提示符立即移到下一行。C:\> myFormApp.exe
C:\> # this line will display immediately
我知道使用
cmd /c
将等待应用程序退出。C:\> cmd /c myFormApp.exe
C:\> # this line will display after myFormApp.exe closed
即使没有 cmd /c
,我仍希望等待。
是否有任何方法可以防止命令提示符转到新行,而不编辑 myFormApp.exe 源代码?
将 AllocConsole
添加到 Windows 应用程序将显示控制台,但它不会使命令提示符等待退出。
if (args.Length > 0)
{
// Command line given, display console
AllocConsole();
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
任何建议都将不胜感激。谢谢!