One of the biggest differences between Windows applications and standard C programs is the way they receive user input.
In the DOS environment, a program reads from the keyboard by making an explicit call to a function, such as getchar. The function typically waits until the user presses a key before returning the character code to the program. In contrast, in the Windows environment, Windows receives all input from the keyboard, mouse, and timer, and places the input in the appropriate application's “message queue.” When the application is ready to retrieve input, it simply reads the next input message from its message queue.
In the standard DOS environment, input is typically in the form of 8-bit characters from the keyboard. The standard input functions, getchar and fscanf, read characters from the keyboard and return ASCII or other codes corresponding to the keys pressed. A program can also intercept interrupts from input devices such as the mouse and timer to use information from those devices as input.
In Windows, an application receives input in the form of “input messages” that Windows sends it. A Windows input message contains information that far exceeds the type of input information available in the standard DOS environment. It specifies the system time, the position of the mouse, the state of the keyboard, the scan code of the key (if a key is pressed), the mouse button pressed, as well as the device generating the message. For example, there are two keyboard messages, WM_KEYDOWN and WM_KEYUP, that correspond to the press and release of a specific key. With each keyboard message, Windows provides a device-independent virtual-key code that identifies the key, the device-dependent scan code generated by the keyboard, as well as the status of other keys on the keyboard, such as SHIFT, CTRL, and NUMLOCK. Keyboard, mouse, and timer messages all have the same format and are all processed in the same manner.