Mega Code Archive

 
Categories / Delphi / Examples
 

Using Console in non console applications

Title: Using Console in non-console applications. Question: How to implement console input/output for non-console applications? Answer: For implementing console input/output for non-console applications you should use the AllocConsole and FreeConsole functions. Example below demonstrates using these functions: procedure TForm1.Button1Click(Sender: TObject); var s: string; begin AllocConsole; try Write('Type here your words and press ENTER: '); Readln(s); ShowMessage(Format('You typed: "%s"', [s])); finally FreeConsole; end; end;