On my research list: Not sure why, but sometimes the Delphi options display a regular application, but the IsConsole returns true because of AppType Console in the main PropertyGroup.
- console applications are turned off in the linker

- the debugger still shows it as a console application when stepping through the
initializationsection of theSystemunit

One of the problems is that unlike the {$APPTYPE directive (which has not changed much over time), the AppType element is undocumented (hardly anything in the .dproj file is documented).
The $APPTYPE lists two values: Console and GUI, defaulting to GUI:
- [WayBack] Application type (Delphi 2007)
- [WayBack] Application type (Delphi 2009)
- [WayBack] Application type (Delphi 10.2 Tokyo) – RAD Studio
Empirically, the AppType element can have these values:
ApplicationConsolePackage
This is the topmost part of the .dproj file does not matter, without AppType element valued Console, or with it or even having it valued Application: either way a console application is being built.
There is no $APPTYPE in the .dpr or any of the .pas files.
The IsConsole variable is always false and a console window always appears when debugging.
- [WayBack] System.IsConsole Variable (Delphi 2007)
- [WayBack] System.IsConsole Variable (Delphi 2009)
- [WayBack] System.IsConsole – RAD Studio API Documentation (Delphi 10.2 Tokyo)
That variable is not always conclusive, as there are situations where code is inside a BPL or DLL started by an EXE, so this works better: [WayBack] How to determine if I’m running as a console app? (Delphi on Win32) – Stack Overflow:
function IAmAConsoleApp: Boolean; var Stdout: THandle; begin Stdout := GetStdHandle(Std_Output_Handle); Win32Check(Stdout <> Invalid_Handle_Value); Result := Stdout <> 0; end;
The .dproj files:





