Windows API
Encyclopedia
The Windows API, informally WinAPI, is Microsoft's core set of application programming interface
s (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 on 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
.
Developer support is available in the form of the Microsoft Windows SDK, providing documentation and tools necessary to build software based upon the Windows API and associated Windows interfaces.
Base Services: Provide access to the fundamental resources available to a Windows system. Included are things like file systems, devices
, processes
and threads
, and error handling. These functions reside in kernel.exe, krnl286.exe or krnl386.exe files on 16-bit Windows, and kernel32.dll on 32-bit Windows.
Advanced Services
Graphics Device Interface: Provides functionality for outputting graphical content to monitors
, printers
and other output devices. It resides in gdi.exe on 16-bit Windows, and gdi32.dll on 32-bit Windows in user-mode. Kernel-mode GDI support is provided by
User Interface: Provides the functionality to create and manage screen window
s and most basic controls, such as button
s and scrollbar
s, receive mouse and keyboard input, and other functionality associated with the GUI
part of Windows. This functional unit resides in user.exe on 16-bit Windows, and 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).
Common Dialog Box Library: Provides applications the standard dialog box
es for opening and saving files, choosing 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.
Common Control Library: Gives applications access to some advanced controls provided by the operating system. These include things like status bar
s, progress bar
s, toolbar
s and tab
s. The library resides in a 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.
Windows Shell: Component of the Windows API allows applications to access the functionality provided by the operating system shell, as well as change and enhance it. The component resides in shell.dll on 16-bit Windows, and shell32.dll on 32-bit Windows. The Shell Lightweight Utility Functions are in shlwapi.dll. It is grouped under the User Interface category of the API.
Network Services: Give access to the various networking
capabilities of the operating system. Its sub-components include NetBIOS
, Winsock
, NetDDE, RPC
and many others.
web browser also exposes many APIs that are often used by applications, and as such could be considered a part of the Windows API. Internet Explorer has been included with the operating system since Windows 95 OSR2, and has provided web related services to applications since Windows 98
. Specifically, it is used to provide:
set of APIs as part of every Windows installation since Windows 95
OSR2. DirectX provides a loosely related set of multimedia and gaming services, including:
and an application. For communication between the different Windows applications among themselves, Microsoft has developed a series of technologies alongside the main Windows API. This started out 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 quite a lot of overlap.
The variety of terms is basically the result of grouping software mechanisms that relate to a particular aspect of software development. Automation specifically relates to exporting the functionality of an application or component (as an API
) so that it can be controlled by another application instead of just by a human user, .NET is a self-contained general methodology and technology for developing Desktop and Web applications written in a variety of "Just in Time" compiled languages.
s were developed by Microsoft that took over some of the more low level functions of the Windows API, and allowed applications to interact with the API in a more abstract manner. Microsoft Foundation Class Library
(MFC) wrapped Windows API functionality in C++
classes
, and thus allows a more object oriented
way of interacting with the API. The Active Template Library (ATL) is a template
oriented wrapper for COM. The Windows Template Library
(WTL) was developed as an extension to ATL, and intended as a lightweight alternative to MFC.
Also notable are some of Borland's
offerings. Object Windows Library
(OWL) was released to compete with MFC, and offered a similar object-oriented wrapper. Borland later deprecated
it in favour of the Visual Component Library
(VCL), which is written in Object Pascal
and available in both Delphi
and C++ Builder
.
Most application framework
s for Windows (at least partially) wrap the Windows API. Thus, the .NET Framework
and Java
, likewise any other programming languages under Windows, are (or contain) wrapper libraries.
Windows API Code Pack for Microsoft .NET Framework is a .Net wrapper library for Windows API.
.
Charles Petzold
, writer of several books about programming against the Windows API, has said: "The original hello world program
in the Windows 1.0 SDK was a bit of a scandal. HELLO.C was about 150 lines long, and the HELLO.RC resource script had another 20 or so more lines. (...) Veteran C programmers often curled up in horror or laughter when encountering the Windows hello-world program."
Over the years, various changes and additions were made to the Windows Operating System, and the Windows API changed and grew to reflect this. The Windows API for Windows 1.0
supported fewer than 450 function calls
, where in modern versions of the Windows API there are thousands. However, in general, the interface remained fairly consistent, and an old Windows 1.0 application will still look familiar to a programmer who is used to the modern Windows API.
An emphasis has been made by Microsoft
on maintaining software backwards compatibility. To achieve this, when developing a new version of Windows, Microsoft sometimes had to implement workarounds to allow compatibility with third-party software that used the previous version's API in an undocumented or even (programmatically) illegal way. Raymond Chen, a Microsoft developer who works on the Windows API, has said: "I could probably write for months solely about bad things apps do and what we had to do to get them to work again (often in spite of themselves). Which is why I get particularly furious when people accuse Microsoft of maliciously breaking applications during OS upgrades. If any application failed to run on Windows 95, I took it as a personal failure."
One of the largest changes the Windows API underwent was the transition from Win16 (shipped in Windows 3.1 and older) to Win32 (Windows NT and Windows 95 and up). While Win32 was originally introduced with Windows NT 3.1
and Win32s
allowed usage of a Win32 subset before Windows 95, it was not until Windows 95 that widespread porting of applications to Win32 began. To ease the transition, in Windows 95, both for external developers and for Microsoft itself, a complex scheme of API thunk
s was used that could allow 32 bit code to call into 16 bit code and (for the majority of Win16 APIs) vice-versa. Flat thunks allowed 32 bit code to call into 16 bit libraries, and the scheme was used extensively inside Windows 95's libraries to avoid porting the whole OS to Win32 itself in one chunk. In Windows NT, the OS was pure 32-bit (except the parts for compatibility with 16-bit applications), and only generic thunks were available to thunk from Win16 to Win32, as for Windows 95. The Platform SDK shipped with a compiler that could produce the code necessary for these thunks.
The Wine
project is an attempt to provide a Win32 API compatibility layer
for Unix-like
platforms. ReactOS
goes a step further and aims to provide an implementation of the entire Windows operating system, working closely with the Wine project to promote code re-use and compatibility. DosWin32
and HX DOS-Extender
are other projects which emulate the Windows API allowing the execution of simple Windows programs from a DOS
command line. Odin
is a project to emulate Win32 on top of OS/2
.
Windows Interface Source Environment
(or WISE) was a licensing program from Microsoft which allowed developers to recompile and run Windows-based applications on UNIX and Macintosh platforms.
WISE SDKs were based on an emulation of the Windows API which could run on Unix and Macintosh platforms.
(interface definition language) files. Collectively, these prerequisites (compilers, tools, libraries, and headers) are known as the Microsoft Platform SDK
. For a long time, the Microsoft Visual Studio
family of compiler
s and tools and Borland
's compilers were the only tools that could provide this (although at least in the case of Windows, the SDK itself is downloadable for free separately from the entire IDE
suite, from Microsoft Windows SDK for Windows 7 and .NET Framework 4). Nowadays, the MinGW
and Cygwin
projects also provide such an environment based on the GNU Compiler Collection
, using a stand-alone header file collection to make linking against Microsoft DLLs possible. LCC-Win32 is a "free for non-commercial use" C compiler maintained by Jacob Navia. Pelles C
is another freeware C compiler maintained by Pelle Orinius. Free Pascal
is a free software
Object Pascal
compiler capable of writing software based on the Windows API. The MASM32 package is a mature project providing support for the Windows API under Microsoft's Macro Assembler by using custom made or converted headers and libraries from the Platform SDK.
Windows specific compiler support is also required for the Structured Exception Handling
feature (SEH). This system serves a dual purpose: it provides a substrate upon 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 itself will be dealt with by the default backstop handler, which pops up the Windows common crash dialog.
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...
s (APIs) available in the Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
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 on 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
Windows NT Startup Process
The Windows NT startup process is the process by which Windows NT 4.0, Windows 2000, Windows XP and Windows Server 2003 operating systems initialize...
) use the Native API
Native API
The Native API is the publicly- and incompletely-documented application programming interface used internally by the Windows NT family of operating systems produced by Microsoft.. It is predominately used during system boot, when other components of Windows are unavailable. The Program Entry point...
.
Developer support is available in the form of the Microsoft Windows SDK, providing documentation and tools necessary to build software based upon the Windows API and associated Windows interfaces.
Overview
The functionality provided by the Windows API can be grouped into eight categories:Base Services: Provide access to the fundamental resources available to a Windows system. Included are things like file systems, devices
Computer hardware
Personal computer hardware are component devices which are typically installed into or peripheral to a computer case to create a personal computer upon which system software is installed including a firmware interface such as a BIOS and an operating system which supports application software that...
, processes
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...
and threads
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...
, and error handling. These functions reside in kernel.exe, krnl286.exe or krnl386.exe files on 16-bit Windows, and kernel32.dll on 32-bit Windows.
Advanced Services
- Provide access to functionality additional to the kernel. Included are things like the Windows registryWindows registryThe Windows Registry is a hierarchical database that stores configuration settings and options on Microsoft Windows operating systems. It contains settings for low-level operating system components as well as the applications running on the platform: the kernel, device drivers, services, SAM, user...
, shutdown/restart the system (or abort), start/stop/create a Windows serviceWindows ServiceOn Microsoft Windows operating systems, a Windows service is a long-running executable that performs specific functions and which is designed not to require user intervention. Windows services can be configured to start when the operating system is booted and run in the background as long as...
, manage user accounts. These functions reside in advapi32.dll on 32-bit Windows.
Graphics Device Interface: Provides functionality for outputting graphical content to monitors
Computer display
A monitor or display is an electronic visual display for computers. The monitor comprises the display device, circuitry, and an enclosure...
, printers
Computer printer
In computing, a printer is a peripheral which produces a text or graphics of documents stored in electronic form, usually on physical print media such as paper or transparencies. Many printers are primarily used as local peripherals, and are attached by a printer cable or, in most new printers, a...
and other output devices. It resides in gdi.exe on 16-bit Windows, and gdi32.dll on 32-bit Windows in user-mode. Kernel-mode GDI support is provided by
win32k.sys
which communicates directly with the graphics driver.User Interface: Provides the functionality to create and manage screen window
Window (computing)
In computing, a window is a visual area containing some kind of user interface. It usually has a rectangular shape that can overlap with the area of other windows...
s and most basic controls, such as button
Button (computing)
In computing, a button is a user interface element that provides the user a simple way to trigger an event, like searching for a query at a search engine, or to interact with dialog boxes, like confirming an action.-Description:A typical button is a rectangle or rounded rectangle, wider than it is...
s and scrollbar
Scrollbar
A scrollbar is an object in a graphical user interface with which continuous text, pictures or anything else can be scrolled including time in video applications, i.e., viewed even if it does not fit into the space in a computer display, window, or viewport...
s, receive mouse and keyboard input, and other functionality associated with the GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...
part of Windows. This functional unit resides in user.exe on 16-bit Windows, and user32.dll on 32-bit Windows. Since Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
versions, the basic controls reside in comctl32.dll, together with the common controls (Common Control Library).
Common Dialog Box Library: Provides applications the standard dialog box
Dialog box
In a graphical user interface of computers, a dialog box is a type of window used to enable reciprocal communication or "dialog" between a computer and its user. It may communicate information to the user, prompt the user for a response, or both...
es for opening and saving files, choosing 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.
Common Control Library: Gives applications access to some advanced controls provided by the operating system. These include things like status bar
Status bar
A status bar, similar to a status line, is an information area typically found at the bottom of windows in a graphical user interface.A status bar is sometimes divided into sections, each of which shows different information. Its job is primarily to display information about the current state of...
s, progress bar
Progress bar
A progress bar is a component in a graphical user interface used to convey the progress of a task, such as a download or file transfer. Often, the graphic is accompanied by a textual representation of the progress in a percent format....
s, toolbar
Toolbar
In a graphical user interface, on a computer monitor, a toolbar is a GUI widget on which on-screen buttons, icons, menus, or other input or output elements are placed. Toolbars are seen in office suites, graphics editors, and web browsers...
s and tab
Tab (GUI)
In the area of graphical user interfaces , a tabbed document interface is one that allows multiple documents to be contained within a single window, using tabs as a navigational widget for switching between sets of documents...
s. The library resides in a DLL
Dynamic-link library
Dynamic-link library , or DLL, is Microsoft's implementation of the shared library concept in the Microsoft Windows and OS/2 operating systems...
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.
Windows Shell: Component of the Windows API allows applications to access the functionality provided by the operating system shell, as well as change and enhance it. The component resides in shell.dll on 16-bit Windows, and shell32.dll on 32-bit Windows. The Shell Lightweight Utility Functions are in shlwapi.dll. It is grouped under the User Interface category of the API.
Network Services: Give access to the various networking
Computer network
A computer network, often simply referred to as a network, is a collection of hardware components and computers interconnected by communication channels that allow sharing of resources and information....
capabilities of the operating system. Its sub-components include NetBIOS
NetBIOS
NetBIOS is an acronym for Network Basic Input/Output System. It provides services related to the session layer of the OSI model allowing applications on separate computers to communicate over a local area network. As strictly an API, NetBIOS is not a networking protocol...
, Winsock
Winsock
In computing, the Windows Sockets API , which was later shortened to Winsock, is a technical specification that defines how Windows network software should access network services, especially TCP/IP. It defines a standard interface between a Windows TCP/IP client application and the underlying...
, NetDDE, RPC
Remote procedure call
In computer science, a remote procedure call is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space without the programmer explicitly coding the details for this remote interaction...
and many others.
Web
The Internet ExplorerInternet Explorer
Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...
web browser also exposes many APIs that are often used by applications, and as such could be considered a part of the Windows API. Internet Explorer has been included with the operating system since Windows 95 OSR2, and has provided web related services to applications since Windows 98
Windows 98
Windows 98 is a graphical operating system by Microsoft. It is the second major release in the Windows 9x line of operating systems. It was released to manufacturing on 15 May 1998 and to retail on 25 June 1998. Windows 98 is the successor to Windows 95. Like its predecessor, it is a hybrid...
. Specifically, it is used to provide:
- An embeddable web browser control, contained in shdocvw.dll and mshtml.dllTrident (layout engine)Trident is the name of the layout engine for the Microsoft Windows version of Internet Explorer.It was first introduced with the release of Internet Explorer version 4.0 in October 1997; it has been steadily upgraded and remains in use today...
. - 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.
- A library for assisting with 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 Book.
Multimedia
Microsoft has provided the DirectXDirectX
Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay,...
set of APIs as part of every Windows installation since Windows 95
Windows 95
Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...
OSR2. DirectX provides a loosely related set of multimedia and gaming services, including:
- Direct3DDirect3DDirect3D is part of Microsoft's DirectX application programming interface . Direct3D is available for Microsoft Windows operating systems , and for other platforms through the open source software Wine. It is the base for the graphics API on the Xbox and Xbox 360 console systems...
for access to 3D hardware accelerated graphics. - DirectDrawDirectDrawDirectDraw is part of Microsoft's DirectX API. DirectDraw is used to render graphics in applications where top performance is important. DirectDraw also allows applications to run fullscreen or embedded in a window such as most other MS Windows applications. DirectDraw uses hardware acceleration if...
for hardware accelerated access to the 2D framebuffer. As of DirectX 8, this component has been deprecated in favor of Direct3D, which provides more general high-performance graphics functionality (as 2D rendering is a subset of 3D rendering). - DirectSoundDirectSoundDirectSound is a software component of the Microsoft DirectX library for the Windows operating system. DirectSound provides a low-latency interface to the sound card driver and can handle the mixing and recording of multiple audio streams....
for low level hardware accelerated sound card access. - DirectInputDirectInputIn computing, DirectInput is a Microsoft API for collecting input from a computer user, via input devices such as the mouse, keyboard, joystick or other game controllers. It also provides a system for action mapping, which allows the user to assign specific actions within a game to the buttons and...
for communication with input devices such as joysticks and gamepads. - DirectPlayDirectPlayDirectPlay is part of Microsoft's DirectX API. DirectPlay is a network communication library intended for computer game development, although its general nature certainly allows it to be used for other purposes....
as a multiplayer gaming infrastructure. This component has been deprecated as of DirectX 9 and Microsoft no longer recommends its use for game development. - DirectShowDirectShowDirectShow , codename Quartz, is a multimedia framework and API produced by Microsoft for software developers to perform various operations with media files or streams. It is the replacement for Microsoft's earlier Video for Windows technology...
which builds and runs generic multimedia pipelines. It is comparable to the GStreamerGStreamerGStreamer is a pipeline-based multimedia framework written in the C programming language with the type system based on GObject.GStreamer allows a programmer to create a variety of media-handling components, including simple audio playback, audio and video playback, recording, streaming and editing...
framework and is often used to render in-game videos and build media players (Windows Media PlayerWindows Media PlayerWindows Media Player is a media player and media library application developed by Microsoft that is used for playing audio, video and viewing images on personal computers running the Microsoft Windows operating system, as well as on Pocket PC and Windows Mobile-based devices...
is based upon it). DirectShow is no longer recommended for game development. - DirectMusicDirectMusicDirectMusic is a deprecated component of the Microsoft DirectX API that allows music and sound effects to be composed and played and provides flexible interactive control over the way they are played. Architecturally, DirectMusic is a high-level set of objects, built on top of DirectSound, that...
- allows playing of MIDI files, deprecated.
Program interaction
The Windows API mostly concerns itself with the interaction between the operating systemOperating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
and an application. For communication between the different Windows applications among themselves, Microsoft has developed a series of technologies alongside the main Windows API. This started out with Dynamic Data Exchange
Dynamic Data Exchange
Dynamic Data Exchange is a technology for interprocess communication under Microsoft Windows or OS/2.- Overview :Dynamic Data Exchange was first introduced in 1987 with the release of Windows 2.0 as a method of interprocess communication so that one program can communicate with or control another...
(DDE), which was superseded by Object Linking and Embedding
Object Linking and Embedding
Object Linking and Embedding is a technology developed by Microsoft that allows embedding and linking to documents and other objects. For developers, it brought OLE Control eXtension , a way to develop and use custom user interface elements...
(OLE) and later by the Component Object Model
Component Object Model
Component Object Model is a binary-interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range of programming languages...
(COM), Automation Objects
OLE Automation
In Microsoft Windows applications programming, OLE Automation , is an inter-process communication mechanism based on Component Object Model that was intended for use by scripting languages – originally Visual Basic – but now are used by languages run on Windows...
, ActiveX controls
ActiveX
ActiveX is a framework for defining reusable software components in a programming language-independent way. Software applications can then be composed from one or more of these components in order to provide their functionality....
, and the .NET Framework
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
. There is not always a clear distinction between these technologies, and there is quite a lot of overlap.
The variety of terms is basically the result of grouping software mechanisms that relate to a particular aspect of software development. Automation specifically relates to exporting the functionality of an application or component (as an API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...
) so that it can be controlled by another application instead of just by a human user, .NET is a self-contained general methodology and technology for developing Desktop and Web applications written in a variety of "Just in Time" compiled languages.
Wrapper libraries
Various wrapperWrapper
Wrapper generally refers to a type of packaging, such as a flat sheet made out of paper, cellophane or plastic to enclose an object.Wrapper may also refer to:* Wrapper , a woman's garment which is worn over nightwear or lingerie...
s were developed by Microsoft that took over some of the more low level functions of the Windows API, and allowed applications to interact with the API in a more abstract manner. Microsoft Foundation Class Library
Microsoft Foundation Class Library
The Microsoft Foundation Class Library is a library that wraps portions of the Windows API in C++ classes, including functionality that enables them to use a default application framework...
(MFC) wrapped Windows API functionality in C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
classes
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...
, and thus allows a more object oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
way of interacting with the API. The Active Template Library (ATL) is a template
Template (programming)
Templates are a feature of the C++ programming language that allow functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one....
oriented wrapper for COM. The Windows Template Library
Windows Template Library
The Windows Template Library is a free software, object-oriented C++ template library for Win32 development. WTL was created by Microsoft employee Nenad Stefanovic for internal use and later released as an unsupported add-on to Visual Studio and the Win32 Framework SDK...
(WTL) was developed as an extension to ATL, and intended as a lightweight alternative to MFC.
Also notable are some of Borland's
Borland
Borland Software Corporation is a software company first headquartered in Scotts Valley, California, Cupertino, California and finally Austin, Texas. It is now a Micro Focus subsidiary. It was founded in 1983 by Niels Jensen, Ole Henriksen, Mogens Glad and Philippe Kahn.-The 1980s:...
offerings. Object Windows Library
Object Windows Library
The Object Windows Library is a Borland C++ object-oriented framework originally designed for WinAPI. It was used in Turbo Pascal for Windows, Borland Pascal and their Borland C++ package. It was a competitor to the Microsoft Foundation Class Library .OWL had incomplete support by the Borland C++...
(OWL) was released to compete with MFC, and offered a similar object-oriented wrapper. Borland later deprecated
Deprecation
In the process of authoring computer software, its standards or documentation, deprecation is a status applied to software features to indicate that they should be avoided, typically because they have been superseded...
it in favour of the Visual Component Library
Visual Component Library
VCL is a visual component-based object-oriented framework for developing Microsoft Windows applications. It was developed by Borland for use in, and tightly integrated with, its Delphi and C++Builder RAD tools...
(VCL), which is written in Object Pascal
Object Pascal
Object Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Embarcadero Delphi.-Early history at Apple:...
and available in both Delphi
Borland Delphi
Embarcadero Delphi is an integrated development environment for console, desktop graphical, web, and mobile applications.Delphi's compilers use its own Object Pascal dialect of Pascal and generate native code for 32- and 64-bit Windows operating systems, as well as 32-bit Mac OS X and iOS...
and C++ Builder
C++ Builder
C++Builder is a rapid application development environment, developed by Borland and owned by Embarcadero Technologies, for writing programs in the C++ programming language. C++Builder combines the Visual Component Library and IDE written in Delphi with a C++ compiler...
.
Most application framework
Application framework
In computer programming, an application framework consists of a software framework used by software developers to implement the standard structure of an application for a specific development environment ....
s for Windows (at least partially) wrap the Windows API. Thus, the .NET Framework
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
and Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
, likewise any other programming languages under Windows, are (or contain) wrapper libraries.
Windows API Code Pack for Microsoft .NET Framework is a .Net wrapper library for Windows API.
History
The Windows API has always exposed a large part of the underlying structure of the Windows systems to the programmer. This has had the advantage of giving Windows programmers a great deal of flexibility and power over their applications. However, it also has given Windows applications a great deal of responsibility in handling various low-level, sometimes tedious, operations that are associated with a graphical user interfaceGraphical user interface
In computing, a graphical user interface is a type of user interface that allows users to interact with electronic devices with images rather than text commands. GUIs can be used in computers, hand-held devices such as MP3 players, portable media players or gaming devices, household appliances and...
.
Charles Petzold
Charles Petzold
Charles Petzold is an American programmer and technical author on Microsoft Windows applications. He is also a Microsoft Most Valuable Professional....
, writer of several books about programming against the Windows API, has said: "The original hello world program
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...
in the Windows 1.0 SDK was a bit of a scandal. HELLO.C was about 150 lines long, and the HELLO.RC resource script had another 20 or so more lines. (...) Veteran C programmers often curled up in horror or laughter when encountering the Windows hello-world program."
Over the years, various changes and additions were made to the Windows Operating System, and the Windows API changed and grew to reflect this. The Windows API for Windows 1.0
Windows 1.0
Windows 1.0 is a 16-bit graphical operating environment, developed by Microsoft and released on 20 November 1985. It was Microsoft's first attempt to implement a multi-tasking graphical user interface-based operating environment on the PC platform. Windows 1.0 was the first version of Windows...
supported fewer than 450 function calls
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....
, where in modern versions of the Windows API there are thousands. However, in general, the interface remained fairly consistent, and an old Windows 1.0 application will still look familiar to a programmer who is used to the modern Windows API.
An emphasis has been made by Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...
on maintaining software backwards compatibility. To achieve this, when developing a new version of Windows, Microsoft sometimes had to implement workarounds to allow compatibility with third-party software that used the previous version's API in an undocumented or even (programmatically) illegal way. Raymond Chen, a Microsoft developer who works on the Windows API, has said: "I could probably write for months solely about bad things apps do and what we had to do to get them to work again (often in spite of themselves). Which is why I get particularly furious when people accuse Microsoft of maliciously breaking applications during OS upgrades. If any application failed to run on Windows 95, I took it as a personal failure."
One of the largest changes the Windows API underwent was the transition from Win16 (shipped in Windows 3.1 and older) to Win32 (Windows NT and Windows 95 and up). While Win32 was originally introduced with Windows NT 3.1
Windows NT 3.1
Windows NT 3.1 is the first release of Microsoft's Windows NT line of server and business desktop operating systems, and was released to manufacturing on 27 July 1993. The version number was chosen to match the one of Windows 3.1, the then-latest operating environment from Microsoft, on account of...
and Win32s
Win32s
Win32s is a 32-bit application runtime environment for the Microsoft Windows 3.1 and 3.11 operating systems. It allowed some 32-bit applications to run on the 16-bit operating system using call thunks.- Concept and Characteristics :...
allowed usage of a Win32 subset before Windows 95, it was not until Windows 95 that widespread porting of applications to Win32 began. To ease the transition, in Windows 95, both for external developers and for Microsoft itself, a complex scheme of API thunk
Thunk
Thunk may refer to:* Thunk , a piece of code to perform a delayed computation * Thunk : a feature of some virtual function table implementations...
s was used that could allow 32 bit code to call into 16 bit code and (for the majority of Win16 APIs) vice-versa. Flat thunks allowed 32 bit code to call into 16 bit libraries, and the scheme was used extensively inside Windows 95's libraries to avoid porting the whole OS to Win32 itself in one chunk. In Windows NT, the OS was pure 32-bit (except the parts for compatibility with 16-bit applications), and only generic thunks were available to thunk from Win16 to Win32, as for Windows 95. The Platform SDK shipped with a compiler that could produce the code necessary for these thunks.
Versions
Almost every new version of Microsoft Windows has introduced its own additions and changes to the Windows API. The name of the API, however, remained consistent between different Windows versions, and name changes were kept limited to major architectural and platform changes for Windows. Microsoft eventually changed the name of the then current Win32 API family into Windows API, and made it into a catch-all term for both past and future versions of the API.- Win16 is the API for the first, 16-bit16-bit-16-bit architecture:The HP BPC, introduced in 1975, was the world's first 16-bit microprocessor. Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816. The Intel 8088 was program-compatible with the Intel 8086, and was 16-bit in that its registers were 16...
versions of Microsoft WindowsMicrosoft WindowsMicrosoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
. These were initially referred to as simply the "Windows API", but were later renamed to Win16 in an effort to distinguish them from the newer, 32-bit version of the Windows API. The functions of Win16 API mainly reside in the core files of the OS: kernel.exe (or krnl286.exe or krnl386.exe), user.exe and gdi.exe. Despite the file extension of exe, these actually are dynamically linked libraries. - Win32 is the 32-bit32-bitThe range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....
APIApplication programming interfaceAn application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...
for modern versions of Windows. The API consists of functions implemented, as with Win16, in system DLLs. The core DLLs of Win32 are kernel32.dll, user32.dll, and gdi32.dll. Win32 was introduced with Windows NTWindows NTWindows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...
. The version of Win32 shipped with Windows 95Windows 95Windows 95 is a consumer-oriented graphical user interface-based operating system. It was released on August 24, 1995 by Microsoft, and was a significant progression from the company's previous Windows products...
was initially referred to as Win32c, with the "c" standing for "compatibility", but this term was later abandoned by Microsoft in favour of Win32. - Win32sWin32sWin32s is a 32-bit application runtime environment for the Microsoft Windows 3.1 and 3.11 operating systems. It allowed some 32-bit applications to run on the 16-bit operating system using call thunks.- Concept and Characteristics :...
is an extension for the Windows 3.1x family of Microsoft Windows that implemented a subsetSubsetIn mathematics, especially in set theory, a set A is a subset of a set B if A is "contained" inside B. A and B may coincide. The relationship of one set being a subset of another is called inclusion or sometimes containment...
of the Win32 API for these systems. The "s" stands for "subset". - Win32 for 64-bit Windows, previously known as Win64, is the variant of the API implemented on 64-bit64-bit64-bit is a word size that defines certain classes of computer architecture, buses, memory and CPUs, and by extension the software that runs on them. 64-bit CPUs have existed in supercomputers since the 1970s and in RISC-based workstations and servers since the early 1990s...
platforms of the Windows architectureArchitecture of the Windows NT operating system lineThe architecture of Windows NT, a line of operating systems produced and sold by Microsoft, is a layered design that consists of two main components, user mode and kernel mode. It is a preemptive, reentrant operating system, which has been designed to work with uniprocessor and symmetrical multi...
( AMD64X86-64x86-64 is an extension of the x86 instruction set. It supports vastly larger virtual and physical address spaces than are possible on x86, thereby allowing programmers to conveniently work with much larger data sets. x86-64 also provides 64-bit general purpose registers and numerous other...
and IA-64.) Both 32-bit and 64-bit versions of an application can be still compiled from a single codebaseCodebaseThe term codebase, or code base, is used in software development to mean the whole collection of source code used to build a particular application or component. Typically, the codebase includes only human-written source code files, and not, e.g., source code files generated by other tools or...
, although some older APIs have been deprecated, and some of the APIs that were already deprecated in Win32 were entirely removed. All memory pointers are 64-bit by default (the LLP64 model), so the source code has to be checked for compatibility with 64-bit pointer arithmetic and rewritten as necessary.
Other implementations
Although Microsoft's implementation of the Windows API is copyrighted, it is generally accepted due to legal precedents in the United States that other vendors can emulate Windows by providing an identical API (but not an identical implementation in code) without breaching copyright.The Wine
Wine (software)
Wine is a free software application that aims to allow computer programs written for Microsoft Windows to run on Unix-like operating systems. Wine also provides a software library, known as Winelib, against which developers can compile Windows applications to help port them to Unix-like...
project is an attempt to provide a Win32 API compatibility layer
Compatibility layer
A compatibility layer is a term that refers to components that allow for non-native support of components.In software engineering, a compatibility layer allows binaries for a legacy or foreign system to run on a host system. This translates system calls for the foreign system into native system...
for Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
platforms. ReactOS
ReactOS
ReactOS is an open source computer operating system intended to be binary compatible with application software and device drivers made for Microsoft Windows NT versions 5.x and up...
goes a step further and aims to provide an implementation of the entire Windows operating system, working closely with the Wine project to promote code re-use and compatibility. DosWin32
DosWin32
DosWin32 is a DOS extender aiming to provide a Win32 API emulation layer. Limited DPMI support is also available.Author is Yury Haron ....
and HX DOS-Extender
HX DOS Extender
The HX DOS Extender is a free DOS extender with built-in Win32 PE file format support. Usually the purpose of a DOS extender is to make protected mode features, especially large memory and 32-bit addressing, available for DOS applications. HX fully supports this goal, but goes some steps further...
are other projects which emulate the Windows API allowing the execution of simple Windows programs from a DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...
command line. Odin
Odin (software)
In computing, Odin is a project to run Microsoft Windows programs on OS/2 or convert them to OS/2 native format. It also provides the Odin32 API to compile Win32 programs for OS/2.The project's goals are:...
is a project to emulate Win32 on top of OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...
.
Windows Interface Source Environment
Windows Interface Source Environment
Windows Interface Source Environment was a licensing program from Microsoft which allowed developers to recompile and run Windows-based applications on UNIX and Macintosh platforms....
(or WISE) was a licensing program from Microsoft which allowed developers to recompile and run Windows-based applications on UNIX and Macintosh platforms.
WISE SDKs were based on an emulation of the Windows API which could run on Unix and Macintosh platforms.
Compiler support
To develop software that utilizes the Windows API, a compiler must be able to handle and import the Microsoft-specific DLLs and COM-objects. The compiler must either handle the header files that expose the interior API function names, or supply such files by itself. For certain classes of applications, the compiler system should also be able to handle IDLInterface description language
An interface description language , or IDL for short, is a specification language used to describe a software component's interface...
(interface definition language) files. Collectively, these prerequisites (compilers, tools, libraries, and headers) are known as the Microsoft Platform SDK
Microsoft Platform SDK
Microsoft Windows SDK, Platform SDK, and .NET Framework SDK are software development kits from Microsoft that contain header files, libraries, samples, documentation and tools required to develop applications for Microsoft Windows and .NET Framework....
. For a long time, the Microsoft Visual Studio
Microsoft Visual Studio
Microsoft Visual Studio is an integrated development environment from Microsoft. It is used to develop console and graphical user interface applications along with Windows Forms applications, web sites, web applications, and web services in both native code together with managed code for all...
family of compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
s and tools and Borland
Borland
Borland Software Corporation is a software company first headquartered in Scotts Valley, California, Cupertino, California and finally Austin, Texas. It is now a Micro Focus subsidiary. It was founded in 1983 by Niels Jensen, Ole Henriksen, Mogens Glad and Philippe Kahn.-The 1980s:...
's compilers were the only tools that could provide this (although at least in the case of Windows, the SDK itself is downloadable for free separately from the entire IDE
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...
suite, from Microsoft Windows SDK for Windows 7 and .NET Framework 4). Nowadays, the MinGW
MinGW
MinGW , formerly mingw32, is a native software port of the GNU Compiler Collection and GNU Binutils for use in the development of native Microsoft Windows applications; MinGW can function either as a cross compiler targeting Windows or as a native toolchain run on Windows itself...
and Cygwin
Cygwin
Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment...
projects also provide such an environment based on the GNU Compiler Collection
GNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
, using a stand-alone header file collection to make linking against Microsoft DLLs possible. LCC-Win32 is a "free for non-commercial use" C compiler maintained by Jacob Navia. Pelles C
Pelles C
Pelles C is a lightweight freeware integrated development environment for Windows and Pocket PC programming in the C language built and maintained by Pelle Orinius, featuring:* Integrated source code editor with Win32 API call tips, and auto indenting....
is another freeware C compiler maintained by Pelle Orinius. Free Pascal
Free Pascal
Free Pascal Compiler is a free Pascal and Object Pascal compiler.In addition to its own Object Pascal dialect, Free Pascal supports, to varying degrees, the dialects of several other compilers, including those of Turbo Pascal, Delphi, and some historical Macintosh compilers...
is a free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...
Object Pascal
Object Pascal
Object Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Embarcadero Delphi.-Early history at Apple:...
compiler capable of writing software based on the Windows API. The MASM32 package is a mature project providing support for the Windows API under Microsoft's Macro Assembler by using custom made or converted headers and libraries from the Platform SDK.
Windows specific compiler support is also required for the Structured Exception Handling
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....
feature (SEH). This system serves a dual purpose: it provides a substrate upon 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 itself will be dealt with by the default backstop handler, which pops up the Windows common crash dialog.
See also
- Object Windows LibraryObject Windows LibraryThe Object Windows Library is a Borland C++ object-oriented framework originally designed for WinAPI. It was used in Turbo Pascal for Windows, Borland Pascal and their Borland C++ package. It was a competitor to the Microsoft Foundation Class Library .OWL had incomplete support by the Borland C++...
- .NET Framework.NET FrameworkThe .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
- Microsoft Foundation Class LibraryMicrosoft Foundation Class LibraryThe Microsoft Foundation Class Library is a library that wraps portions of the Windows API in C++ classes, including functionality that enables them to use a default application framework...
- Microsoft Windows library files
- InterixInterixInterix is the name of an optional, full-featured POSIX and Unix environment subsystem for Microsoft's Windows NT-based operating systems.Interix is a component of the Services for Unix release 3.0 and 3.5...
External links
- MSDN Windows API
- C++ Win32 API Tutorial
- Straight C Win32 API Tutorial no MFC
- [news://comp.os.ms-windows.programmer.win32 Advanced Win32 api newsgroup]
- [news://fr.comp.os.ms-windows.programmation French Win32 api newsgroup]
- Windows API Code Pack for Microsoft .NET Framework
- ECMA-234 - ECMAEcma InternationalEcma International is an international, private non-profit standards organization for information and communication systems. It acquired its name in 1994, when the European Computer Manufacturers Association changed its name to reflect the organization's global reach and activities...
standard for a subset of the Windows API - Windows API - Developers discussion forum - Win32 API discussion forum.
- winapiexec - a tool to run WinAPI functions from command line.