Windows项目中的控制台 [英] Console in Windows project

查看:158
本文介绍了Windows项目中的控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为Forms的项目在我的

解决方案中保留一些表格和内容。


启动时的参数定义使用From或Console。

我的计划是创建一个myConsole类,它也允许我的应用程序

显示一个控制台,但我似乎不允许这样做。


我没有看到任何我需要添加的参考文献,所以我该怎么做。

I got a project called "Forms" that hold some forms and stuff in my
solution.

A argument at startup defines wether to use a From or Console.

My plan was to create a myConsole class that would also allow my application
to display a Console, but i don''t seem to be allowed to do this.

I don''t see any References that i need to add, so how do i do this.

推荐答案

文章< 68 ****************************** @ news.teranews.co m> ;, Jarod_24写道:
In article <68******************************@news.teranews.co m>, Jarod_24 wrote:
我有一个名为Forms的项目在我的
解决方案中包含一些形式和内容。

启动时的参数定义使用From或Console。

我的计划是创建一个myConsole这个类也可以让我的应用程序显示一个控制台,但我似乎不允许这样做。

我没有看到任何我需要的参考资料添加,所以我该怎么做。
I got a project called "Forms" that hold some forms and stuff in my
solution.

A argument at startup defines wether to use a From or Console.

My plan was to create a myConsole class that would also allow my application
to display a Console, but i don''t seem to be allowed to do this.

I don''t see any References that i need to add, so how do i do this.




您可以尝试将您的应用程序创建为常规表单应用程序。

然后如果你收到命令行参数在控制台中运行,你可以通过p / invoke调用AllocConsole来分配一个控制台窗口。在

之后,System.Console类应该可以工作....


-

Tom Shelton [MVP] < br $>
操作系统名称:Microsoft Windows XP Professional

操作系统版本:5.1.2600 Service Pack 1 Build 2600



You might try creating your application as a regular forms application.
Then if you recieve the command line argument to run in a console, you
can call AllocConsole via p/invoke to allocate a console window. After
that, the System.Console class should work....

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 9 Days, 0 Hours, 52 Minutes, 41 Seconds


" Tom Shelton" < to*@mtogden.com>在消息中写道

news:eI ************** @ TK2MSFTNGP12.phx.gbl ...
"Tom Shelton" <to*@mtogden.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
在文章< 68 ******************************@news.teranews.co m> ;, Jarod_24
In article <68******************************@news.teranews.co m>, Jarod_24



写道:


wrote:

我有一个名为Forms的项目在我的
解决方案中包含一些形式和内容。

启动时的参数定义使用From或Console。

我的计划是创建一个myConsole这个类也允许我的
应用程序显示一个控制台,但我似乎不允许这样做。

我没有看到任何我需要的参考文献添加,所以我该怎么做。
I got a project called "Forms" that hold some forms and stuff in my
solution.

A argument at startup defines wether to use a From or Console.

My plan was to create a myConsole class that would also allow my application to display a Console, but i don''t seem to be allowed to do this.

I don''t see any References that i need to add, so how do i do this.



您可能会尝试将您的应用程序创建为常规表单应用程序。
然后,如果您收到命令行参数在控制台中运行,您可以通过p / invoke调用AllocConsole来分配控制台窗口。
之后,System.Console类应该可以工作....

- Tom Shelton [MVP]
操作系统名称:Microsoft Windows XP Professional 系统启动时间:9天,0小时,52分钟,41秒



You might try creating your application as a regular forms application.
Then if you recieve the command line argument to run in a console, you
can call AllocConsole via p/invoke to allocate a console window. After
that, the System.Console class should work....

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 9 Days, 0 Hours, 52 Minutes, 41 Seconds



它有效!

我现在在基于表单的项目中有一个控制台窗口。


我可以使用Console.ReadLine来获取用户输入的任何内容

控制台,但是Console.WriteLine不能正常工作。

因此无论我试图写入控制台窗口,都不会出现。


我是否必须使用API​​来正确地读取/写入控制台


还有更多技巧?


It worked!
I now got a console window in my forms-based project.

I can use the Console.ReadLine to get whatever the user types in the
console, but the Console.WriteLine dosen''t work.
So whatever i try to write to the console window, dosen''t show up.

Do i have to use the API for reading/writing properly to/from the console

Got any more tricks up your sleeve?

< br>

在文章< a2 ****************************** @ news.teranews.co m>中, Jarod_24写道:
In article <a2******************************@news.teranews.co m>, Jarod_24 wrote:
" Tom Shelton" < to*@mtogden.com>在消息中写道
新闻:eI ************** @ TK2MSFTNGP12.phx.gbl ...
"Tom Shelton" <to*@mtogden.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
文章< 68 **** **************************@news.teranews.co m> ;, Jarod_24
In article <68******************************@news.teranews.co m>, Jarod_24


写道:

>我有一个名为Forms的项目在我的
>中保留一些表格和内容解决方案。
>
>启动时的参数定义使用From或Console。
>
>我的计划是创建一个myConsole类,它也允许我的应用程序>显示一个控制台,但我似乎不允许这样做。
>
>我没有看到任何我需要添加的参考文献,所以我该怎么做。
>
>
> I got a project called "Forms" that hold some forms and stuff in my
> solution.
>
> A argument at startup defines wether to use a From or Console.
>
> My plan was to create a myConsole class that would also allow my application > to display a Console, but i don''t seem to be allowed to do this.
>
> I don''t see any References that i need to add, so how do i do this.
>
>



你可能会尝试创建你的应用程序作为常规表单应用程序。
然后,如果您收到在控制台中运行的命令行参数,您可以通过p / invoke调用AllocConsole来分配控制台窗口。
之后,System.Console类应该可以工作....

- Tom Shelton [MVP]
操作系统名称:Microsoft Windows XP Professional 系统启动时间:9天,0小时,52分钟,41秒



You might try creating your application as a regular forms application.
Then if you recieve the command line argument to run in a console, you
can call AllocConsole via p/invoke to allocate a console window. After
that, the System.Console class should work....

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 9 Days, 0 Hours, 52 Minutes, 41 Seconds



它有效!
我现在在基于表单的项目中有一个控制台窗口。

我可以使用Console.ReadLine来获取用户在
控制台中输入的任何内容,但是Console.WriteLine dosen'工作。
所以无论我试图写入控制台窗口,都不会出现。

我是否必须使用API​​来正确读取/写入控制台

你的袖子还有什么技巧吗?


It worked!
I now got a console window in my forms-based project.

I can use the Console.ReadLine to get whatever the user types in the
console, but the Console.WriteLine dosen''t work.
So whatever i try to write to the console window, dosen''t show up.

Do i have to use the API for reading/writing properly to/from the console

Got any more tricks up your sleeve?




嗯,不起作用...有趣的是readline做和写作

不行。你是否附带调试器(F5)运行它?如果你是的话,它没有(Ctrl + F5)



如果这不起作用,请告诉我,我会玩转一些代码:)

-

Tom Shelton [MVP]

操作系统名称:Microsoft Windows XP Professional

操作系统版本:5.1.2600 Service Pack 1 Build 2600

系统启动时间:0天,1小时,38分钟,49秒



Hmmm, doesn''t work... Interesting that readline does and writeline
doesn''t. Are you running it with the Debugger attached (F5)? If you are, it
without (Ctrl+F5).

If that doesn''t work, let me know and I''ll play around with some code :)
--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 0 Days, 1 Hours, 38 Minutes, 49 Seconds


这篇关于Windows项目中的控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆