Cool, thanks. I have set as apptype console, then freeconsole if the GUI
part is going to be used. This seems to work fine.

Dave. 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Corey Murtagh
Sent: Wednesday, 27 October 2004 1:36 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Partial Console App.

David O'Brien wrote:
> Hi all,
> Is it possible to create a single app that generates a console window 
> if the correct parameters are used, but a GUI app otherwise?
> I have code in my dpr that only runs the app if there are no 
> parameters, but how do I generate the console window for output?
> Conversely, I can call the app a console app, {$APPTYPE CONSOLE}, and 
> still use the GUI part if required, but how do I get rid of the 
> console window?

Console and GUI (including VCL GUI) apps are different in the way they
appear to the OS.  Before the point where the executable's code is
called the OS does some things dependant on the subsystem specified in
the exe's headers.  If it's a console app then the standard I/O handles
- input, output and error - are connected to the parent console, and a
console is created at this point if necessary.  GUI apps don't get
those, since they run independant of any console.

With a GUI application however you /can/ create a console window using
the AllocConsole API.  In theory you can connect to an existing console
window using the AttachConsole API, but you need to pass in the process
id of another program, and there's no guarantee that you're going to get
anything useful.

Whether you allocate or attach you'll still need to fix up the input and
output file pointers so that your I/O routines work.  You might need to
do a Reset(input), Rewrite(output) or something... whatever Delphi needs
to be told that the standard handles have changed.

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi




_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to