/SUBSYSTEM:Windows 程序不会写入命令行
我在 Visual Studio 2005 中有一个混合模式 C++-CLI 程序,该程序设置为使用 /SUBSYSTEM:Windows。一般来说,它是一个图形应用程序,从其快捷方式或通过注册到它的文件类型启动。
但是,在极少数情况下,用户希望使用参数从命令行运行它。我可以很好地访问参数,当涉及到写入控制台时,响应从带有参数的命令行启动的程序,我没有看到 Console::WriteLine
有任何效果。
我做错了什么?
I have a mixed mode C++-CLI program in Visual Studio 2005 that is set to use the /SUBSYSTEM:Windows. Generally speaking it is a graphical application that is launched from its shortcut or through the filetype registered to it.
However, there is a rare occasion where a user will want to run it from the command line with arguments. I can access the arguments just fine, its when it comes to writing to the console, in response to the program being launched from the command line with arguments, where I don't see Console::WriteLine
having any effect.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很烦人,我同意。你没有做错什么,这是 Windows 设置方式的一个怪癖。
至少在某些情况下可以解决此问题,请参阅 http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx。不过,我还没有遇到任何其他人真正使用过这些方法。
大多数人的 IME 只是创建两个版本的具有不同名称的可执行文件,一种用于批处理用户(“myapp.exe”),另一种用于从开始菜单运行时(“myappw.exe”)。
有关详细信息,请参阅 如何输出到控制台中的一些建议C++/Windows 可能有用。
This one's annoying, I agree. You're not doing anything wrong, it's a quirk of the way Windows is set up.
It is possible to solve this, at least in some cases, see http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx . I've not come across anybody else who's actually used these methods though.
Most people IME just create two versions of the executable with different names, one for batch users ("myapp.exe") and one for when it's run from the start menu ("myappw.exe").
For more information, some of the suggestions at How to output to the console in C++/Windows may be useful.
这是一个老问题 - 请参阅 http://www.codeproject.com/KB/cpp/ EditBin.aspx 的解决方案
您还可以重新打开控制台编辑流
:抱歉,这是纯 C++,不了解 C++/cli
It's an old problem - see http://www.codeproject.com/KB/cpp/EditBin.aspx for solutions
You can also reopen the streams to a console
edit: sorry this is pure C++, don't know about C++/cli