Showing posts with label Chapter1. Show all posts
Showing posts with label Chapter1. Show all posts

Friday, February 22, 2008

Introduction

Win 32 API Programming:


Interface:

Any program is defined to be a set of instructions given by the programmer to the computer for processing.
The user who is using the program should see the result of the program or should interact with the program by giving some input to it.
Interface is where the user can interact with the program.

Any user can interact or use the program in two ways.
• With the help of Characters.
• With the help of Graphics.

The interface that contains characters is Character User Interface or CUI.

Example:

DOS operating system has character user interface.

The interface that contains graphics is Graphical User Interface.

Example:

Windows operating system has Graphical User Interface, this is because of the programs with a number of built in functions and data which is not present in other Character User Interface operating system.

Differences between DOS and Windows:

Interaction with hardware devices:

DOS programs directly interact with hardware like memory and printer ports.

Note:
Port is the location where we can interact with the hardware devices.




Windows provides device drivers and functions, so that our program can call them
Whenever they wanted to use.

Note:
Device drivers are special programs required to access any Hardware devices.
They will drive to and from the devices.

And the functions, provided by windows in order to use any hardware device are
called GDI (Graphical Device Interface) functions.

GDI functions internally take the help of a data structure called Device Context, in order to get the information about the hardware devices.

Windows maintains information about output devices in an internal structure called Device Context.

Programming model:

DOS Program model:

DOS programs call the operating system to get the input directly.
Whenever a DOS application starts complete control over the system resources like CPU, memory is given to it.

The DOS application waits for the user to input, then it takes a particular action.
Internally as it waits, it continues controlling the system resources and the control is not given to any other applications till the current application is closed.

Whenever an I/O (input output) event occurs, the information goes directly to the application but not to the operating system.


Windows Program model:

Where as windows programs process the input with the help of messages sent by the operating system.

Windows is responsible for all I/O events like mouse clicks, keystrokes etc…

When an event is generated windows figures out which window application is currently active and sends the information about the event to the current or active application.

The below figure shows that:

In other words, all messages that event is generated is stored in the form of a queue called system queue, which is maintained by windows.

From the system queue, the messages are then sent to applications by windows and stored in appropriate application message queues.

It is the responsibility of the applications to read the queue and process the messages.