控制台应用

控制台应用

问题描述:

是否可以拥有一个既是控制台应用程序又是Windows应用程序的应用程序?

如果没有命令行开关,那么它将作为控制台应用程序运行,如果

有命令行开关然后它将是一个Windows应用程序。如果我把它变成了一个Windows应用程序,那么我就不能写入控制台了。如果我把它作为一个控制台应用程序

然后它启动一个控制台,如果用户从开始菜单运行它所以从

我看到它是不可能的。


在此先感谢,

Michael

Is it possible to have an app that is both a console app and a windows app?
If there are no command line switches then it will run as a console app, if
there are command line switches then it will be a windows app. If I make it
a windows app then I can''t write to the console. If I make it a console app
then it starts a console if the user runs it from the start menu so from
what I see it''s not possible.

Thanks in advance,
Michael

Michael C写道:
Michael C wrote:

是否可以拥有一个既是控制台应用程序又是Windows应用程序的应用程序?
Is it possible to have an app that is both a console app and a windows app?



是的。只需从控制台应用程序打开一个窗口表单。

Yes. Just open a windows form from a console application.


如果没有命令行开关,那么它将作为控制台应用程序运行,如果

有命令行开关然后它将是一个Windows应用程序。
If there are no command line switches then it will run as a console app, if
there are command line switches then it will be a windows app.



这是不可能的。启动后你不能将非控制台应用程序变成一个

,你必须先启动应用程序,然后才能检查命令行。

That''s not possible. You can''t turn a non-console application into one
after it has started, and you have to start the application before you
can check the command line.


如果我把它变成

a windows app那么我就不能写入控制台了。如果我把它变成一个控制台应用程序

然后它启动一个控制台,如果用户从开始菜单运行它所以从

我看到它是不可能的。
If I make it
a windows app then I can''t write to the console. If I make it a console app
then it starts a console if the user runs it from the start menu so from
what I see it''s not possible.



你可以让一个控制台应用程序启动一个Windows版本的

程序,如果它在命令行中找不到任何东西。


你可以通过打开一个像控制台窗口一样工作的窗体来伪造控制台窗口。


-

G?ran Andersson

_____
http://www.guffa.com


Michael:


当你建立项目,你可以指定项目是否在
控制台模式。所有这些意味着Windows将默认创建一个默认控制台

。我通常编写WinForms应用程序,我特定为

控制台。这使我能够在我的

应用程序中执行像Console.WriteLine()这样的操作来进行简单的跟踪和调试。当您关闭控制台时,

它只是意味着Windows不会创建默认控制台。


如前面的回复所述,您无法在运行时选择此项-time -

子系统(Windows / Console)需要在编译/链接时确定。


请注意,从WinForms类型的应用程序,你可以随时创建你自己的

控制台。


jpuopolo

" Michael C" < no **** @ nospam.comwrote in message

news:OF **************** @ TK2MSFTNGP05.phx.gbl ...
Michael:

When you build the project, you can specifiy whether the project is in
console mode. All this means is that Windows will create a default console
by default. I typically write WinForms applications that I specificy as
Console. This enables me to do things likes Console.WriteLine() in my
application to do simply tracing and debugging. When you turn off Console,
it simply means that Windows will not create a default Console.

As the previous reply states, you cannot choose this at run-time -- the
subsystem (Windows/Console) needs to be decided at compile/link time.

Note that from a WinForms-type application, you can always create your own
Console explicitly.

jpuopolo
"Michael C" <no****@nospam.comwrote in message
news:OF****************@TK2MSFTNGP05.phx.gbl...

是否可以拥有一个既是控制台应用又是windows

app的应用?如果没有命令行开关,那么它将作为控制台运行

应用程序,如果有命令行开关那么它将是一个Windows应用程序。如果

我把它变成了一个Windows应用程序,那么我就不能写入控制台了。如果我把它设为一个

控制台应用程序,那么它会启动一个控制台,如果用户从开始

菜单运行它,那么我认为这是不可能的。


提前致谢,

Michael

Is it possible to have an app that is both a console app and a windows
app? If there are no command line switches then it will run as a console
app, if there are command line switches then it will be a windows app. If
I make it a windows app then I can''t write to the console. If I make it a
console app then it starts a console if the user runs it from the start
menu so from what I see it''s not possible.

Thanks in advance,
Michael





" Michael C" < no **** @ nospam.comwrote in message

news:OF **************** @ TK2MSFTNGP05.phx.gbl ...

"Michael C" <no****@nospam.comwrote in message
news:OF****************@TK2MSFTNGP05.phx.gbl...

是否可以拥有一个既是控制台应用又是windows

app的应用?如果没有命令行开关,那么它将作为控制台运行

应用程序,如果有命令行开关那么它将是一个Windows应用程序。如果

我把它变成了一个Windows应用程序,那么我就不能写入控制台了。如果我把它设为一个

的控制台应用程序,那么如果用户从开始

菜单运行它就会启动一个控制台,所以从我看来它是不可能的。
Is it possible to have an app that is both a console app and a windows
app? If there are no command line switches then it will run as a console
app, if there are command line switches then it will be a windows app. If
I make it a windows app then I can''t write to the console. If I make it a
console app then it starts a console if the user runs it from the start
menu so from what I see it''s not possible.



是的。把它写成一个Windows应用程序,但告诉编译器它是一个控制台应用程序。

然后它将可以访问控制台,它可以避免实际打开任何
打开任何如果这就是你想要的窗户。


- 另一个Michael C.

Yes. Write it as a windows app but tell the compiler it''s a console app.
Then it will have access to the console, and it can refrain from actually
opening any windows if that''s what you want.

- The other Michael C.