使用AttachConsole,用户必须按回车键来获得常规命令行 [英] Using AttachConsole, user must hit enter to get regular command line
问题描述
我有一个可以运行无论是作为一个WinForm一个progaram,或命令行。如果从命令行调用我打电话AttachConsole(-1),附加到父控制台。
I have a progaram that can be ran both as a winform, or from command line. If it is invoked from a command line I call AttachConsole(-1) to attach to parent console.
不过,我的程序结束后,用户必须按回车键得到回标准的命令提示符(C:\>)。有没有办法避免的需要?
However, after my program ends, the user must hit enter to get back the standard command prompt ("c:\>"). is there a way to avoid that need?
感谢。
我可以将它包装在一个cmd文件,以避免这个问题,但我想从我的exe做到这一点。
Thanks. I could wrap it in a cmd file to avoid that issue, but I would like to do it from my exe.
推荐答案
只是试试你的EXE退出前加入这一行...
Try adding this line just before your exe exits...
System.Windows.Forms.SendKeys.SendWait({} ENTER);
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
位,但最好的时候,我遇到了这个问题,我能找到。
Bit of a hack, but best I could find when I encountered that problem.
罗布
这篇关于使用AttachConsole,用户必须按回车键来获得常规命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!