function PauseConsole(Prompt: PAnsiChar): boolean;
var
hStdIn, hStdOut: THandle;
dwRd, dwWr, i: Cardinal;
cBuf: array [0..128] of TInputRecord;
begin
result := false;
hStdIn := GetStdHandle(STD_INPUT_HANDLE);
hStdOut := GetStdHandle(STD_OUTPUT_HANDLE);
if ((hStdIn <> 0) and (hStdOut <> 0)) then
begin
WriteFile(hStdOut,Prompt[0],lstrlenA(Prompt),dwWr,nil);
while ReadConsoleInput(hStdIn,cBuf[0],128,dwRd) do
begin
for i := 0 to dwRd do
begin
if ((cBuf[i].EventType = KEY_EVENT) and (cBuf[i].Event.KeyEvent.bKeyDown)) then
begin
Result := true;
exit;
end;
end;
end;
end;
end;
try
PauseConsole('Press a key to continue...');
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;