thpatch / win32_utf8

Transparent UTF-8 support for native Win32 ANSI applications
The Unlicense
99 stars 7 forks source link

Question regarding "entry_*.c": App with Console and GUI modes #6

Closed Amaroq-Clearwater closed 3 months ago

Amaroq-Clearwater commented 4 years ago

If I'm trying to make a program that can execute both in console and in a GUI, like if I use a command-line argument in the shortcut "-console" that launches a console alongside the GUI version, or "-nogui" which disables the GUI and automatically launches the console, which entry file am I supposed to use?

brliron commented 4 years ago

When you make a program like that, you usually start without a console, then create one with AllocConsole. Because you start without a console, you will use entry_winmain.c .

32th-System commented 4 years ago

And if you want to use things like printf you also need to do

freopen("CONIN$", "r", stdin); 
freopen("CONOUT$", "w", stdout); 
freopen("CONOUT$", "w", stderr);