Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is System.IsConsole true in Delphi?

Tags:

console

delphi

According to System.pas, it is documented as True if compiled as console app. In System.pas, there is also an assignment

{$IFDEF LINUX}
  IsConsole := True;
...

I have a strange problem where an app is launched from a Delphi app, using ShellExecute, and then it runs into this code, raising the (unexpected) exception

  if System.IsConsole then
    raise Exception.Create(Msg)

The application is not compiled with Project/Options/Linking/Generate console application. What else could set IsConsole to true?


Note that in Delphi XE2, OSX applications can not use this variable as it is always true. See QC Entry 98956 and Why Does My OSX FireMonkey App Think It Is a Console App ?

like image 808
mjn Avatar asked Aug 10 '11 13:08

mjn


1 Answers

Found it: the executable has been created using dcc32.exe and the dpr / cfg file, the cfg contains a line

-cc

which creates a console application.

The Delphi 2009 Enterprise IDE does not show this setting in the Project/Options/Linking/Generate console application dialog. The application was ported from an older Delphi version and maybe something went wrong over the years.

like image 167
mjn Avatar answered Oct 17 '22 05:10

mjn