There is an application that (initially unknown) neither the form nor the console may be initially as both may already be present (both the console and the form).
How to determine the absence of the console and create it if it is not?
You can create a console only if it is not there, so you can simply call AllocConsole without any conditions. Proof :
Remarks
AllocConsole function fails if there is a console.
In general, you can use GetConsoleWindow, for example, to check the console
In either case, this is either a console or a GUI. It is determined by the compiler at the build stage. See the structure of PE files.
Technically easier to hide the console, run a cycle of forms. In Delphi, this is quite simple to implement.
Source: https://ru.stackoverflow.com/questions/280736/
All Articles