home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / com / bbs / uupc / source / lib / setstdin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-10  |  1.3 KB  |  47 lines

  1. /*
  2.  *    $Id: SETSTDIN.C 1.1 1993/04/10 21:22:29 dmwatt Exp $
  3.  *
  4.  *    $Log: SETSTDIN.C $
  5.  * Revision 1.1  1993/04/10  21:22:29  dmwatt
  6.  * Initial revision
  7.  *
  8.  *     Revision 1.1  1993/04/09  06:22:00  dmwatt
  9.  *     Written
  10.  
  11. *
  12.  */
  13.  
  14. /*--------------------------------------------------------------------*/
  15. /*                        System include files                        */
  16. /*--------------------------------------------------------------------*/
  17.  
  18. #include <stdio.h>
  19.  
  20. #ifdef WIN32
  21.  
  22. #include <windows.h>
  23.  
  24. /*--------------------------------------------------------------------*/
  25. /*    s e t s t d i n m o d e                                         */
  26. /*                                                                    */
  27. /*    Set standard input on NT console for single char I/O            */
  28. /*--------------------------------------------------------------------*/
  29.  
  30. void setstdinmode(void)
  31. {
  32.    HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
  33.    DWORD mode;
  34.    BOOL bSuccess;
  35.  
  36.    bSuccess = GetConsoleMode(hStdIn, &mode);
  37.  
  38. /* Disable mouse events so that later Peeks() only get characters */
  39.    mode &= ~ENABLE_WINDOW_INPUT;
  40.    mode &= ~ENABLE_MOUSE_INPUT;
  41.    mode &= ~ENABLE_LINE_INPUT;
  42.    mode |= ENABLE_PROCESSED_INPUT;
  43.  
  44.    SetConsoleMode(hStdIn, mode);
  45. }
  46.  
  47. #endif
  48.