test: twait.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# twait.c File Reference

`#include "precomp.h"`

Go to the source code of this file.

## Functions

DWORD | main (VOID)

## Function Documentation

DWORD main | ( | VOID |  | ) |

Definition at line 11 of file twait.c.

References BOOL, DWORD, FALSE, FlushConsoleInputBuffer(), Status, and STD_INPUT_HANDLE.

    00012 {
    00013     DWORD Status;
    00014     ULONG BytesTransferred;
    00015     INPUT_RECORD Char;
    00016     BOOL Success;
    00017     HANDLE Array[1];
    00018     int i;
    00019
    00020     FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
    00021     for (i=0;i<2;i++) {
    00022         printf("Waiting...\n");
    00023         Status = WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE),-1);
    00024         if (Status != 0) {
    00025             printf("wait failed %lx\n",Status);
    00026             return 1;
    00027         }
    00028         Success = ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE),
    00029                            &Char,
    00030                            1,
    00031                            &BytesTransferred
    00032                           );
    00033         if (Status != 0) {
    00034             printf("read failed %lx\n",Status);
    00035             return 1;
    00036         }
    00037         if (BytesTransferred != 1) {
    00038            printf("Read returned %d chars\n",BytesTransferred);
    00039         }
    00040         printf("Read returned %c\n",Char.Event.KeyEvent.uChar.AsciiChar);
    00041     }
    00042
    00043     Array[0] = GetStdHandle(STD_INPUT_HANDLE);
    00044     for (i=0;i<2;i++) {
    00045         printf("Waiting...\n");
    00046         Status = WaitForMultipleObjects(1,Array,FALSE,-1);
    00047         if (Status != 0) {
    00048             printf("wait failed %lx\n",Status);
    00049             return 1;
    00050         }
    00051         Success = ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE),
    00052                            &Char,
    00053                            1,
    00054                            &BytesTransferred
    00055                           );
    00056         if (Status != 0) {
    00057             printf("read failed %lx\n",Status);
    00058             return 1;
    00059         }
    00060         if (BytesTransferred != 1) {
    00061            printf("Read returned %d chars\n",BytesTransferred);
    00062         }
    00063         printf("Read returned %c\n",Char.Event.KeyEvent.uChar.AsciiChar);
    00064     }
    00065 }