views:

96

answers:

2

What exactly happens when a .NET console application starts?

In the process explorer, when starting the exe I am wondering why I cannot see a "cmd.exe" process as a parent process for the console application. What exactly is displayed then?

Is there a way to replace the "default" console window by another one? I guess this would mean modifying the "console subsystem".

Creating a GUI application instead of a console application is not an option as I do not have the source of all possible tools.

Observation:

  • With Mono and Linux, I have no issue at all regarding this and my test app!
  • The font used has an influence, I cannot find a font that fits for everything (even with asia pack installed)
  • Tweaking (Changing font, sizes, ...) in registry at HKEY_CURRENT_USER\Console is having an impact and can be defined per executable.
+2  A: 

Try to set the Console.OutputEncoding property.

Console.OutputEncoding = Encoding.UTF8;

This will effectively call the Win32 native SetConsoleOutputCP function setting the console code page to the CodePage property of the specified encoding.

Martin Liversage
That is definitively one of the things to do, beside installing support for asian languages. But the fonts, neither raster nor "Lucida Console" are able to display the kanji correctly. With some tricks the font "Consolas" worked. So it turns out cmd.exe unterstands UTF8 but cannot display all chars properly. Still I would like to know how the command line gets integrated into a console application, how tied it is to it and if it's possible to provide a replacement for it.
jdehaan
FWIW the font Japanese Windows uses in the terminal is ‘MS Gothic’.
bobince
+3  A: 
Richard
Thanks now I understand how the magic is done. I always thought erroneoously it was something built into the application. This makes a system-wide cmd.exe (theoretically at least) possible.
jdehaan