How could I create a Console Application that could work with or without a GUI?
For example, say if I had a console application, If i tried launching this console app from Windows Explorer it will not work it will just close, but I could call it from my GUI Application or the Windows Command Console (cmd.exe) and pass some switches (parameters?) to it.
That way some useful functions can be used without even starting the GUI Application, they can be called from the command line.
EDIT
I am not sure how to create the Console Application, especially that would accept flags (switches, parameters?).
I have seen some Applications that do something similar. For example they might have a Console Application that will convert a bmp to a png, and the GUI calls this Console Application and passes the arguments etc to it.
Hope that makes sense.
So how could I employ something like this?
Thanks.
It will work. However, the console window will disappear as soon as your program has exited. If you want to give the user a chance to read the output of your console application before the window is closed, simply end your program with a single
or
If you want to use a console window for output (or input) in a GUI application, you can give the
AllocConsoleandFreeConsolefunctions a try.Command-line arguments (such as
myapp.exe /OPEN "C:\some dir\file.txt" /THENEXIT) can be used in all types of Windows applications, both GUI apps and console apps. Just use theParamCountandParamStrfunctions.How to Create a Console Application that Accepts Command-Line Arguments
In the Delphi IDE, choose File/New/Console Application. Then write
Compile the program. Then open a command processor (CMD.EXE) and go to the directory where
Project1.exeis.Then try
How to pass three arguments