The help you needed in C, C++, MFC
Complete tutorials with free source code

Win 32 API

This tutorial will help you understand the basics of Windows API. If you like to understand what is going on in the lower layers of your programs and in operating system, not just programming using libraries which provide very high level features such as MFC or .NET, you must learn Win32 API. The tutorial will give you the basic understanding on Win32 API.

Let's first see what is an API. API stands for Application Program Interface. So, it is an interface. API is generally an interface provided by an operating system for the programs running on top of it. You know the applications we write do not directly run on the hardware. We need the support of the operating system. For an example, if our program need to create a file on the disk, we do not try to move the disk arms and do it ourselves. Instead, we tell the operating system to create a file for us. For that, we use the API provided by the operating system. In Windows, we can use Win32 API call CreateFile() for create a file.

Different operating systems provide different API s for the programs running on them. Java virtual machine (JVM) also provide an API for the java programs which run on the JVM. Windows provides 3 API s for the programs running on it. Win32, OS2 and POSIX. But, you may have not even seen windows programs which use OS2 or POSIX API s. Actually, these two API s also use Win32 API internally. So Win32 can be considered as the API of the Windows operating systems.

Win32 consists of thousands of function calls which Win32 programs can use for get their work done by the Windows operating system. There are Function calls for process and thread management, file management, user interface management, memory management, power management, administration, system information, registry etc. Because these functions are provided by the operating system, the use of these functions is not limited for C or C++. VB, Pascal and other languages also can use the Win32 API function calls.

Microsoft do not change the Win32 API with different versions of Windows. The internal implementation may differ with different versions, but the interface, function prototypes are kept unchanged. But, new Win32 API calls are added with new versions.

Normally, using the Win32 API directly in our applications is not that convenient. Most of the Win32 functions need large number of arguments passed to them and learning the meaning of each argument and how to use the function correctly is bit a headache. So, instead of using the Win32 directly, what we do is use a framework such as MFC of .Net. These frameworks wrap the actual API provided by windows and provide an easy to use interface for the application programs.

The best place to learn the Win32 API is the MSDN library which is freely available to download from Microsoft (Not the MSDN that comes with Visual Studio. The MSDN version that comes with Visual Studio is a documentation on Visual Studio, not a documentation of Win32 API). MSDN library is a large documentation for the windows platform which includes 3 - 4 GB of html. It includes the documentation of the Win32 API where the usage of each Win32 function is clearly defined. MSDN library is very important resource for any Windows programmer.

It might be somewhat difficult for a beginner to understand how to use a Win32 function correctly by studying the documentation of the function in the MSDN library along. In this tutorial, you can find simpler explanations of some commonly used Win32 functions.

Win32 API Implementation
Commonly Used Win32 Functions