Some highlights from [WayBack] console – When is System.IsConsole true in Delphi? – Stack Overflow:
- – [WayBack] .
- The
-cc
commandline parameter for dcc32.exe (which could be in your ProjectX.cfg file!) is equivalent to “Generate console application):
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. – [WayBack] mjn
- 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 ? – [WayBack] mjn
A few notes I have found out myself
The linker option “” is the same as “DCC_ConsoleTarget
” in the .dproj
file:
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_ConsoleTarget>true</DCC_ConsoleTarget>
</PropertyGroup>
Even setting IsConsole
to True
does not allocate a new console, so the STD_OUTPUT_HANDLE
handle does not work!
The below method in the System
unit, then does not show output:
procedure WriteErrorMessage;
{$IFDEF MSWINDOWS}
var
Dummy: Cardinal;
begin
if IsConsole then
begin
with TTextRec(Output) do
begin
if (Mode = fmOutput) and (BufPos > 0) then
TTextIOFunc(InOutFunc)(TTextRec(Output)); // flush out text buffer
end;
// Leave #0 off end of runErrMsg
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), @runErrMsg, Sizeof(runErrMsg) - 1, Dummy, nil);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), @sLineBreak[1], 2, Dummy, nil);
end
else if not NoErrMsg then
MessageBoxA(0, runErrMsg, errCaption, 0);
end;
For console output, you have to enable the linker option DCC_ConsoleTarget
allocates a console (if not yet allocated), enables the “STD_OUTPUT_HANDLE
” handle, and sets IsConsole
to True
.
–jeroen
Like this:
Like Loading...