首页  编辑  

Press any key to continue...

Tags: /超级猛料/Console.控制台程序/   Date Created:

Press any key to continue...

From Borland NewsGroup

How to do "Press any key to continue..." at console application?

procedure PressAnyKey;

const

 PressAnyKey = 'Press any key to continue...';

var

 Console: Cardinal;

 ConsoleMode: Cardinal;

 Buffer: Char;

 BufferSize: Cardinal;

begin

 Console := GetStdHandle(STD_INPUT_HANDLE);

 WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), PChar(PressAnyKey),

   Length(PressAnyKey), BufferSize, nil);

 GetConsoleMode(Console, ConsoleMode);

 ConsoleMode := ConsoleMode - ENABLE_LINE_INPUT - ENABLE_ECHO_INPUT;

 SetConsoleMode(Console, ConsoleMode);

 ReadConsole(Console, @Buffer, 1, BufferSize, nil);

end;