Windows API
What is the Windows API?
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. It was formerly called the Win32 API; however, the name "Windows API" more accurately reflects its roots in 16-bit Windows and its support in 64-bit Windows. Almost all Windows programs interact with the Windows API; on the Windows NT line of OSes, a small number (such as programs started early in the Windows startup process) use the Native API.
The Windows API is used by every software developer who wants to build applications that target the Windows operating system. In the past, where Windows development was mainly message driven, the developer had to manually write the code that created the window, set up the message processing loop, and react to every user action by receiving messages from the operating system. For example, WM_LBUTTONDOWN tells us that the user has clicked the left mouse button, while WM_PAINT tells the window procedure that the window's client area has changed and must be repainted. The modern integrated development environments (IDEs) hide the complexity of such a programming approach by allowing developers to graphically create the user interface of their applications, following the Rapid Application Development (RAD) paradigm.
Writing every single line of code is not practical and leads to a waste of time, so many software companies developed packages that wrap the big set of Windows APIs in more compact and usable **class libraries ** that simplify the developers' work. For example, Borland introduced the Object Windows Library (OWL), while Microsoft developed the Microsoft Foundation Class (MFC). Today there is the Microsoft .NET Framework.
The large set of libraries and functions that constitute the API are provided to software developers by the Software Development Kit (SDK, also known as Platform SDK), along with a complete set of tools (like compilers and linkers).
The Native API
The Native API (with capitalized N) is the mostly undocumented application programming interface used internally by the Windows NT family of Windows operating systems. It is predominately used during system boot, when other components of Windows are unavailable. The program entry point is called DriverEntry(), the same as for a Windows Device Driver. However, the application runs in Ring 3 the same as a regular Windows Application. Most of the Native API calls are implemented in ntoskrnl.exe and are exposed to user mode by ntdll.dll. Some Native API calls are implemented in user mode directly within ntdll.dll.
While most of Microsoft Windows is implemented using the documented and well-defined Windows API, a few components, such as the Client/Server Runtime Subsystem, are implemented using the Native API, as they can be started earlier in the Windows NT Startup Process when the Windows API is not yet available.
Community Resources
Web Pages
- Windows API List - A list of the reference content for the Windows Application Programming Interface (API) provided by the MSDN Library.
- Microsoft Win32 to Microsoft .NET Framework API Map - This article identifies the Microsoft .NET Framework version 1.0 or 1.1 APIs that provide similar functionality to Microsoft Win32 functions.
- What's New in the Windows API - Each version of Windows introduces new and updated APIs.
Microsoft Knowledge Base Articles
Technical Articles
- Windows with C++ - C++ and the Windows API (MSDN Magazine, July 2011)
See Also
NOTE: the following links are external to the TechNet Wiki.
Books
- Programming Windows, 5th Edition by Charles Petzold (Microsoft Press, November 1998)
- Windows via C/C++, 5th Edition by Jeffrey Richter and Christophe Nasarre (Microsoft Press, November 2007)
Credits
This article was written by Luigi Bruno.
Other Languages
This article is also available in the following languages: