You can use ShowWindow and GetConsoleWindow WinAPi.
Try this sample
{$APPTYPE CONSOLE} uses Windows, SysUtils; function GetConsoleWindow: HWND; stdcall; external kernel32; begin try Writeln('Press enter to hide console the window'); Readln; //hide the console window ShowWindow(GetConsoleWindow, SW_HIDE); //do something Sleep(5000); Writeln('Press enter to exit'); //show the console window ShowWindow(GetConsoleWindow, SW_SHOW); Readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
source share