我有一个程序,既可以作为 winform 运行,也可以从命令行运行.如果它是从命令行调用的,我会调用 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}");
有点小技巧,但是当我遇到这个问题时,我能找到最好的方法.
Bit of a hack, but best I could find when I encountered that problem.
这篇关于使用 AttachConsole,用户必须按 Enter 才能获得常规命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
读取 XML 时忽略空格Ignore whitespace while reading XML(读取 XML 时忽略空格)
带有检查空元素的 XML 到 LINQXML to LINQ with Checking Null Elements(带有检查空元素的 XML 到 LINQ)
在 C# 中读取带有未闭合标签的 XMLReading XML with unclosed tags in C#(在 C# 中读取带有未闭合标签的 XML)
在 C# 中使用 Html 敏捷性解析表格、单元格Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、单元格)
使用 LINQ 从 xml 中删除元素delete element from xml using LINQ(使用 LINQ 从 xml 中删除元素)
解析格式错误的 XMLParse malformed XML(解析格式错误的 XML)