You can write console mode programs, also called command line programs, programs that usually does not use Windows' graphical user interface, using Delphi.

  1. Create a new application using "File | New Application"
  2. Go to the "Project Manager" ("View | Project Manager")
  3. Remove the default form from the project (highlight the unit and hit DELETE -- do not save changes)
  4. Go to "Project Source" ("View | Project Source")
  5. Edit your project source file:

    • Remove code inside "begin" and "end"
    • Replace the "Forms" unit in the "uses" section with "SysUtils"
    • You probably don't need to load the resource file -- remove "{$R *.RES}"
    • Finally place "{$apptype console}" in a line by itself right after the "program" statement.

You just created a console mode program skeleton in Delphi. Now you can add your code inside "begin" and "end." statements.
program console;

{$apptype console}


{ add your code here... }
WriteLn( 'hello, world!' );
By the way, you can add conditional code to your program that would get executed depending on the type of your application, if you happened to write a dual mode program that has a console mode version and a graphical (GUI) version.
For example, if you want to include a piece of code to your program only if it's a console mode program try this:
{$IFDEF CONSOLE}Advertisement

{... add your console mode code here ...}
If you want to check for the same condition during run time, use the "IsConsole" variable. Example:
if( IsConsole )then

{... add your console mode runtime code here ...}