API stands for Application Programming Interface. I won't explain what an API is, because someone has already beautifully noded it. But Windows has an API and it's called (you guessed it) The Windows API.

The Windows API is a humongous and versatile library of predefined functions, constants and typedefs built by Microsoft to provide a pre-fabricated structure which the programmer can use to quickly write Windows applications that look and feel like all other Windows applications.

Typical API functions used in C and C++ include functions such as CreateWindow() - which is used to create a window (but not display it on the screen) - and ShowWindow() - which displays the window on the screen in the familiar structure that all Windows users know and love. It is small building blocks like these which can all be put together quickly and easily by a programmer to get a Windows application running.

There are many more uses of the Windows API other than creating and displaying windows. There are functions which handle multithreading, memory allocation, File I/O, Device I/O, event handling, and any other programming need. There are also functions such as GetMessage() which reads the queue of Windows OS generated messages that let your program know what the user is doing, and DispatchMessage() which tells your program to handle those messages.

The API is basically split into three sections. (There are others, but these are the three big ones that every Windows programmer should learn.). The sections are the User, Kernel and GDI. The kernel section is considered to be the most important, although you could not make a Windows Application without the use of all three. The kernel API functions handle things like memory management, processes and threads - the unseen guts of a program. The User API functions handle the user interface. The message functions described in the previous paragraph, and the Window creation functions are in the User API. The GDI functions handle the graphics used for drawing lines, and circles, blitting bitmaps, and outputting text.

Listing the entire API would (and does) fill up a book, and an explanation of each would fill several books (and does). Needless to say, I won't be attempting it here.

The Windows API is a flat library, meaning that there is no hierarchy, and an object oriented approach is no good because it is used by non-object oriented languages like C. However, a bone was thrown to C++ programmers a few years ago with the creation of the MFC Library which is an object oriented wrapper around the Windows API - with a few extra goodies thrown in for good measure. How robust and well-organized it is will be left as an exercise for the reader. (Personally, I like it, but not as much as the STL).

Log in or registerto write something here or to contact authors.