20100716

_getch() (prg04)

#language :: c/c++ (mingw)
#purpose :: winapi getch implement
#date :: 16072010
#author :: gerganov


TCHAR _getch()
{
         DWORD mode;
         TCHAR chr = 0;
         DWORD cnt;
         //get a handle to stdin
         HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
         //save the current input mode...
         GetConsoleMode(hStdIn,&mode);
         // Clear the mode
         // turn off ENABLE_ECHO_INPUT
         // and ENABLE_LINE_INPUT
         // so that the output will not be echoed
         // and will not pause until the end of
         // a line for input.
         SetConsoleMode(hStdIn,0);
         // Read in 1 char from the input buffer.
         ReadConsole(hStdIn,&chr,sizeof(TCHAR),&cnt,NULL);
         //restore the current input mode.
         SetConsoleMode(hStdIn, mode);
         return chr;
}

#searchterms :: winapi getch implement, readconsole getch, _getch(), getch(), press a key to continue, pause program, no echo get, get char, winapi getch, conio.h getch, winapi conio.h

No comments: