1. Home
  2. Computing & Technology
  3. Delphi Programming

Add Console Input and Output for a GUI Delphi Application

By Zarko Gajic, About.com

If you want to have console input/output for GUI applications you should use the AllocConsole and FreeConsole functions.

The AllocConsole function allocates a new console for the calling process. The FreeConsole function detaches the calling process from its console. Here's the example:

var
   s: string;
begin
  AllocConsole;
  try
    Write('Type something and press [ENTER]') ;
    Readln(s) ;
    ShowMessage('You typed ' + s) ;
  finally
    FreeConsole;
  end;
end;
Note: "pure" console applications are pure 32-bit Windows programs that run without a graphical interface. When a console application is started, Windows creates a text-mode console window through which the user can interact with the application.

Delphi tips navigator:
» How to Execute a JavaScript Code on a TWebBrowser Document
« Is there an Image in the TImage Delphi Control?

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. Delphi 2006 Tips
  7. Add Console Input and Output for a GUI Delphi Application

©2009 About.com, a part of The New York Times Company.

All rights reserved.