I have a winforms application that sometimes used from the command line.
Here is the code (simplified of course):
[STAThread]
static void Main()
{
AttachConsole(ATTACH_PARENT_PROCESS);
Console.WriteLine("Hello");
/*Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());*/
}
If that was a console application the output could be:
C:ConsoleApplicationConsoleApplication.exe
Hello
C:ConsoleApplication\_
In case of windows application its actually:
C:WindowsApplicationWindowsApplication.exe
C:WindowsApplicationHello
_
Can anyone tell me why do we have such difference and is it possible to make my windows application to behave like console when running from cmd?
edit:
I want my windows application to behave like console when running from cmd:
C:WindowsApplicationWindowsApplication.exe
Hello
C:WindowsApplication\_
solution:
As a result I'm running my application as
C:WindowsApplicationstart /wait WindowsApplication.exe
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…