sending output to stdout in a NON console app - Delphi
This is a discussion on sending output to stdout in a NON console app - Delphi ; I have a win32 app (NOT a console app).
I want to be able to send output to the cmd window if the exe is launched
with certain CL parameters.
Is this possible?
TIA...
-
sending output to stdout in a NON console app
I have a win32 app (NOT a console app).
I want to be able to send output to the cmd window if the exe is launched
with certain CL parameters.
Is this possible?
TIA
-
Re: sending output to stdout in a NON console app
const * const char ME wrote:
> I have a win32 app (NOT a console app).
>
> I want to be able to send output to the cmd window if the exe is launched
> with certain CL parameters.
>
> Is this possible?
Yes, it's possibe. Simply change the project type to Console, and it
will work immediately.
If you don't want a console to be created automaticall, whenever your
application is not started from a console, you'll have to CreateConsole
and the like yourself, before output can be sent there.
Or you send your output to a debug window instead of the console. Then
you can keep that window hidden, depending on the CL arguments, or as
long as it didn't receive any output...
DoDi
-
Re: sending output to stdout in a NON console app
const * const char ME wrote:
> I have a win32 app (NOT a console app).
>
> I want to be able to send output to the cmd window if the exe is launched
> with certain CL parameters.
>
> Is this possible?
>
> TIA
>
>
>
why?
you can make your own command window, and then execute
the command yourself - - -
Jim P.
-
Re: sending output to stdout in a NON console app
On Mon, 18 Feb 2008 15:53:19 -0800, const * const char ME wrote:
> I want to be able to send output to the cmd window if the exe is launched
> with certain CL parameters.
>
> Is this possible?
The way I have seen this done is to check if you were started from a
command line or not:
function AttachConsole(dwProcessId
WORD):Bool; stdcall;
external 'kernel32';
procedure TForm1.Button1Click(Sender: TObject);
begin
if AttachConsole($FFFFFFFF) then
begin
ShowMessage('Yup');
WriteLn('To Console');
end
else
begin
ShowMessage('No Console');
end;
end;
--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
-
Re: sending output to stdout in a NON console app
Marc Rohloff [TeamB] wrote:
> On Mon, 18 Feb 2008 15:53:19 -0800, const * const char ME wrote:
>
>> I want to be able to send output to the cmd window if the exe is launched
>> with certain CL parameters.
>>
>> Is this possible?
>
> The way I have seen this done is to check if you were started from a
> command line or not:
>
> function AttachConsole(dwProcessId
WORD):Bool; stdcall;
> external 'kernel32';
>
> procedure TForm1.Button1Click(Sender: TObject);
> begin
> if AttachConsole($FFFFFFFF) then
> begin
> ShowMessage('Yup');
> WriteLn('To Console');
> end
> else
> begin
> ShowMessage('No Console');
> end;
> end;
The problem is that unless your program is marked as a console program
already, the parent console won't be waiting for output from your
program. It will have gone ahead and printed its command prompt to the
screen. Your program will be injecting its output with the parent's.
You simply don't see Windows programs that run in both console and GUI
modes from the same EXE. Instead, you see two separate programs, like
cscript.exe and wscript.exe to run Windows Scripting Host, or java.exe
and javaw.exe to run Java programs. Cscript and java are console
programs; wscript and javaw are not.
--
Rob