Windows API
Win64 is also available.) | |
Developer(s) | Microsoft |
---|---|
Initial release | November 20, 1985 |
Operating system | Microsoft Windows, OS/2 |
Predecessor | DOS API |
Type | API |
License | Proprietary |
Website | https://learn.microsoft.com/en-us/windows/apps/ |
The Windows API, informally WinAPI, is the foundational application programming interface (API) that allows a computer program to access the features of the Microsoft Windows operating system in which the program is running.
Each major version of the Windows API has another name that identifies a compatibility aspect of that version. For example, Win32 is the major version of Windows API that runs on 32-bit systems. The name, Windows API, collectively refers to all versions of this capability of Windows.
Microsoft provides developer support via a software development kit, Microsoft Windows SDK, which includes documentation and tools for building software based on the Windows API.
Services
This section needs to be updated. The reason given is: The categories are out of date, as are the references for it; see, for example, https://learn.microsoft.com/en-us/windows/win32/apiindex/windows-api-list.. (May 2023) |
The functions provided by the Windows API can be grouped into eight categories:[1]
- Base Services
- Provides access to the basic resources available to a Windows system. Included are things like kernel32.dll and KernelBase.dll on 32 and 64 bit Windows. These files reside in the folder \Windows\System32 on all versions of Windows.[2]
- Advanced Services
- Provides access to functions beyond the kernel. Included are things like the Windows registry, shutdown/restart the system (or abort), start/stop/create a Windows service, manage user accounts. These functions reside in advapi32.dll and advapires32.dll on 32-bit Windows.
- Graphics Device Interface
- Provides functions to output graphics content to
- User Interface
- Provides the functions to create and manage screen user32.dll on 32-bit Windows. Since Windows XP versions, the basic controls reside in comctl32.dll, together with the common controls (Common Control Library).[5]
- Common Dialog Box Library
- Provides applications the standard dialog boxes to open and save files, choose color and font, etc. The library resides in a file called commdlg.dll on 16-bit Windows, and comdlg32.dll on 32-bit Windows. It is grouped under the User Interface category of the API.[6]
- Common Control Library
- Gives applications access to some advanced controls provided by the operating system. These include things like tabs. The library resides in a dynamic-link library (DLL) file called commctrl.dll on 16-bit Windows, and comctl32.dll on 32-bit Windows. It is grouped under the User Interface category of the API.[7]
- Windows Shell
- Component of the Windows API allows applications to access functions provided by the
- Network Services
- Give access to the various NetDDE, remote procedure call (RPC) and many more. This component resides in netapi32.dll on 32-bit Windows.[10]
- Web
- The Windows 95 OSR2 and has provided web-related services to applications since Windows 98.[11]Specifically, it is used to provide:
- An embeddable web browser control, contained in shdocvw.dll and mshtml.dll.
- The URL moniker service, held in urlmon.dll, which provides COM objects to applications for resolving URLs. Applications can also provide their own URL handlers for others to use.
- An HTTP client library which also takes into account system-wide Proxy settings (wininet.dll); however, Microsoft has added another HTTP client library called winhttp.dll which is smaller and more suitable for some applications.
- A library to assist multi-language and international text support (mlang.dll).
- DirectX Transforms, a set of image filter components.
- XML support (the MSXML components, held in msxml*.dll).
- Access to the Windows Address Books.
Program interaction
The Windows API is defined in the
Of note, the internal implementation of the API functions has been developed in several languages other than C.[a]
Despite the fact that C is not an
Windows.pas is a
The Windows API is for the most part intended for a program to access operating system features. For communication among different Windows applications, Microsoft has developed a series of technologies alongside Windows API. This started with Dynamic Data Exchange (DDE), which was superseded by Object Linking and Embedding (OLE) and later by the Component Object Model (COM), Automation Objects, ActiveX controls, and the .NET Framework. There is not always a clear distinction between these technologies, and there is much overlap.
The variety of terms is basically the result of grouping software mechanisms that relate to a given aspect of software development. Automation specifically relates to exporting the function of an application or component (as an
Related technologies
Many Microsoft technologies use the Windows API -- as most software running on Windows does. As middle-ware between Windows API and an application, these technologies provide some access to Windows API. Some technologies are described as wrapping Windows API, but this is debatable since no other technology provides or exposes all of the capabilities of Windows API.
- classes, and thus allows a more object-orientedway to interact with the API
- templatelibrary that provides some Windows API access
- Windows Template Library (WTL) was developed as an extension to ATL, and intended as a smaller alternative to MFC
- Most application frameworks for Windows provide some access to Windows API; including .NET runtime and Java virtual machine and any other programming languages targeting Windows
Although almost all Windows programs use the Windows API, on the Windows NT line of operating systems, programs that start early in the
History
The Windows API has always exposed a large part of the underlying structure of the Windows systems to programmers. This had the advantage of giving them much flexibility and power over their applications, but also creates great responsibility in how applications handle various low-level, sometimes tedious, operations that are associated with a graphical user interface.
For example, a beginning C programmer will often write the simple "hello world" as their first assignment. The working part of the program is only a single printf line within the main subroutine. The overhead for linking to the standard I/O library is also only one line:
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
}
The Windows version was still only one working line of code but it required many, many more lines of overhead.
Over the years, various changes and additions were made to Windows systems, and the Windows API changed and grew to reflect this.
Microsoft has made an effort to maintain
One of the largest changes to the Windows API was the transition from Win16 (shipped in Windows 3.1 and older) to
Major versions
Each version of Microsoft Windows contains a version of Windows API, and almost every new version of Microsoft Windows has introduced additions and changes to the Windows API.[22]
The name, Windows API, refers to essentially the same capability in each version of Windows, but there is another name for this capability that is based on major architectural aspects of the Windows version that contains it. When there was only one version, it was simply called Windows API. Then, when the first major update was made, Microsoft gave it the name Win32 and gave the first version the name Win16. The term Windows API refers to both versions and all subsequently developed major versions.[1]
- Win16 is in the file extension of exe, such a file is accessed as a dynamic-link library (DLL).
- Win32 is in the gdi32.dll. Win32 was introduced with Windows NT. In Windows 95, it was initially referred to as Win32c, with c meaning compatibility. This term was later abandoned by Microsoft in favor of Win32.
- Windows 3.1x family of Microsoft Windows that implemented a subsetof the Win32 API for these systems. The "s" stands for "subset".
- Win64 is the version in the pointer arithmetic.[25]
- WinCE is the version in the Windows CEoperating system.
Other implementations
The
Efforts toward standardization included Sun's
Compiler support
To develop software that uses the Windows API, a compiler must be able to use the Microsoft-specific DLLs listed above (COM-objects are outside Win32 and assume a certain vtable layout). The compiler must either handle the header files that expose the interior API function names, or supply such files.
For the language C++, Zortech (later
have all produced well known commercial compilers that have been used often with Win16, Win32s, and Win32. Some of them supplied memory extenders, allowing Win32 programs to run on Win16 with Microsoft's redistributable Win32s DLL. The Zortech compiler was probably one of the first stable and usable C++ compilers for Windows programming, before Microsoft had a C++ compiler.For certain classes of applications, the compiler system should also be able to handle
As of 2016[update], the
Windows specific compiler support is also needed for Structured Exception Handling (SEH). This system serves two purposes: it provides a substrate on which language-specific exception handling can be implemented, and it is how the kernel notifies applications of exceptional conditions such as dereferencing an invalid pointer or stack overflow. The Microsoft/Borland C++ compilers had the ability to use this system as soon as it was introduced in Windows 95 and NT, however the actual implementation was undocumented and had to be reverse engineered for the Wine project and free compilers. SEH is based on pushing exception handler frames onto the stack, then adding them to a linked list stored in thread-local storage (the first field of the thread environment block). When an exception is thrown, the kernel and base libraries unwind the stack running handlers and filters as they are encountered. Eventually, every exception unhandled by the application will be dealt with by the default backstop handler, which pops up the Windows common crash dialog.
See also
- Windows Libraries for OS/2
- Interix
- Linux kernel API
- Microsoft Windows library files
- Windows legacy audio components
- C++/WinRT, a library providing access to Windows Runtime
Notes
- Pascal calling conventionto restore the stack from pushed parameters after a call (although they expect parameters pushed from right to left, as most C compilers do, by default).
- platform.
References
- ^ a b Microsoft Developer Network (July 2005). Overview of the Windows API. Retrieved August 28, 2005.
- ^ Microsoft Developer Network (July 2005). Base Services. Retrieved August 28, 2005.
- ^ Microsoft Developer Network (July 2005). Graphics Device Interface. Retrieved August 28, 2005.
- ^ "G". Microsoft Developer Network. Retrieved January 28, 2009.
- ^ Microsoft Developer Network (July 2005). User Interface. Retrieved August 28, 2005.
- ^ Microsoft Developer Network (2005). Common Dialog Box Library. Retrieved September 22, 2005.
- ^ Microsoft Developer Network (July 2005). Common Control Library. Retrieved August 28, 2005.
- ^ Microsoft Developer Network (July 2005). Windows Shell. Retrieved August 28, 2005.
- ^ Microsoft Developer Network (2005). Shell Programmer's Guide. Retrieved August 28, 2005.
- ^ Microsoft Developer Network (July 2005). Network Services. Retrieved August 28, 2005.
- ^ Microsoft Developer Network (January 2006); Programming and reusing the browser Retrieved January 22, 2006.
- ^ "Walkthrough: Create a traditional Windows Desktop application (C++)". Microsoft Docs. February 23, 2022.
- ^ ISBN 978-1-4302-4585-8.
- ISBN 0672321157.
- ^ Russinovich, Mark (November 2006). "Inside Native Applications". Microsoft Docs. Retrieved April 12, 2022.
- ^ Charles Petzold (December 2001). Programming Microsoft Windows with C#. Microsoft Press. Beyond the Console, page 47.
- ^ Detailed analysis of changes in the Windows API from XP to 10. Retrieved September 08, 2016.
- ^ Charles Petzold (November 11, 1998). Programming Windows, Fifth Edition. Microsoft Press. APIs and Memory Models, page 9.
- ^ Smith, Graham (October 8, 2022). "Windows 95 had special code just to fix a bug in the original SimCity". Rock, Paper, Shotgun.
- Raymond Chen (October 15, 2003). What about BOZOSLIVEHERE and TABTHETEXTOUTFORWIMPS?Retrieved June 29, 2022.
- ^ Hoffman, Chris. "What's the Difference Between the "System32" and "SysWOW64" Folders in Windows?". How-To Geek. Retrieved April 11, 2023.
- ^ The Iseran Project (1996–2001). History of the Windows API. Retrieved October 7, 2005.
- ^ "Windows XP Professional x64 Edition home page". Microsoft.
- ^ "Microsoft 64-bit Computing Overview". Microsoft.
- ^ "MSDN: Getting Ready for 64-bit Windows". Microsoft.
- ^ WISE Archived 2008-03-30 at the Wayback Machine
External links
- MSDN Windows API index
- Windows API Microsoft Code Samples
- ECMA-234 – ECMA standard for a subset of the Windows API
- Advanced Win32 API newsgroup
- French Win32 API newsgroup