Sie sind auf Seite 1von 16

Windows API

From Wikipedia, the free encyclopedia


Jump to: navigation, search
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 on 64-bit Windows. Almost all Windows programs interact with the
Windows API; a small number (such as programs started early in the Windows startup process)
use the Native API.[1]
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 technologies.

Contents
[hide]
• 1 Overview
○ 1.1 Web
○ 1.2 Multimedia
○ 1.3 Program interaction
○ 1.4 Wrapper libraries
• 2 History
• 3 Versions
• 4 Other implementations
• 5 Compiler support
• 6 See also
• 7 Notes
• 8 References
• 9 External links

[edit] Overview
The functionality provided by the Windows API can be grouped into eight categories:[2]
Base Services[3]
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
Provide access to functionality that is an addition on 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 on 32-bit
Windows.
Graphics Device Interface[4]
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 win32k.sys which
communicates directly with the graphics driver.[5]
User Interface[6]
Provides the functionality to create and manage screen windows and most basic controls,
such as buttons and scrollbars, 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[7]
Provides applications the standard dialog boxes 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[8]
Gives applications access to some advanced controls provided by the operating system.
These include things like status bars, progress bars, toolbars and tabs. 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[9][10]
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[11]
Give access to the various networking capabilities of the operating system. Its sub-
components include NetBIOS, Winsock, NetDDE, RPC and many others.
[edit] Web
The Internet Explorer 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 98 Second Edition, and has provided web related
services to applications since Windows 98.[12] Specifically, it is used to provide:
• An embeddable web browser control, contained in shdocvw.dll and mshtml.dll.
• The URL monitor 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.
[edit] Multimedia
Microsoft has provided the DirectX 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:
• Direct3D for access to 3D hardware accelerated graphics.
• DirectDraw 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).
• DirectSound for low level hardware accelerated sound card access.
• DirectInput for communication with input devices such as joysticks and gamepads.
• DirectPlay as a multiplayer gaming infrastructure. This component has been deprecated
as of DirectX 9 and Microsoft no longer recommends its use for game development.
• DirectShow which builds and runs generic multimedia pipelines. It is comparable to the
GStreamer framework and is often used to render in-game videos and build media
players (Windows Media Player is based upon it). DirectShow is no longer recommended
for game development.
• DirectMusic - allows playing of MIDI files, deprecated.
[edit] Program interaction
The Windows API mostly concerns itself with the interaction between the operating 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 (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.
[edit] Wrapper libraries
Various wrappers 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 as a
competing product to 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 frameworks for Windows are (at least partially) wrapping the Windows API.
Thus, the .NET Framework and Java, as well as 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.
Note that in 64-bit versions of Windows, the same naming of the DLL files is used.
[edit] 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 interface.
Charles Petzold, writer of Windows API books,[clarification needed] 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."[13]
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.[14]
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."[15]
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 thunks 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.
[edit] Versions
Almost every new version of Microsoft Windows has introduced its own additions and changes
to the Windows API.[16] The name of the API however was kept consistent between different
Windows version, 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.[2]
• Win16 is the API for the first, 16-bit versions of Microsoft Windows. These were
initially referred to as simply the Windows API, but were later renamed to Win16 in an
effort to distinguish it 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-bit API 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 NT. The version of
Win32 that was shipped with Windows 95 was initially referred to as Win32c, with the
"c" standing for "compatibility", but this term was later abandoned by Microsoft in
favour of Win32.
• Win32s is an extension for the Windows 3.1x family of Microsoft Windows that
implemented a subset 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-bit platforms of the Windows architecture (currently AMD64 and IA-
64.)[17][18][19] Both 32-bit and 64-bit versions of an application can be still compiled from a
single codebase, 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.[20]
[edit] Other implementations
Although Microsoft's implementation of the Windows API is copyrighted, it is generally
accepted due to legal precedents[citation needed] 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 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.
[edit] 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 IDL (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 compilers 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 Platform SDK Update). 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 a free C compiler maintained by Pelle Orinius. Free Pascal is a GPL Object Pascal compiler
capable of writing software based on the Windows API. MASM32 is a mature project to support
the Windows API utilizing the 32 bit Microsoft assembler with 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.
[edit] See also
• Object Windows Library
• .NET Framework
• Microsoft Foundation Class Library
• Microsoft Windows library files
• Interix
[edit] Notes
1. ^ Microsoft TechNet (November 2006). Inside Native Applications. Retrieved December 24,
2008.
2. ^ a b Microsoft Developer Network (July 2005). Overview of the Windows API. Retrieved August
28, 2005.
3. ^ Microsoft Developer Network (July 2005). Base Services. Retrieved August 28, 2005.
4. ^ Microsoft Developer Network (July 2005). Graphics Device Interface. Retrieved August 28,
2005.
5. ^ "G". Microsoft Developer Network. http://msdn.microsoft.com/en-us/library/ms789535.aspx.
Retrieved 2009-01-28.
6. ^ Microsoft Developer Network (July 2005). User Interface. Retrieved August 28, 2005.
7. ^ Microsoft Developer Network (2005). Common Dialog Box Library. Retrieved September 22,
2005.
8. ^ Microsoft Developer Network (July 2005). Common Control Library. Retrieved August 28,
2005.
9. ^ Microsoft Developer Network (July 2005). Windows Shell. Retrieved August 28, 2005.
10.^ Microsoft Developer Network (2005). Shell Programmer's Guide. Retrieved August 28, 2005.
11.^ Microsoft Developer Network (July 2005). Network Services. Retrieved August 28, 2005.
12.^ Microsoft Developer Network (January 2006); Programming and reusing the browser
Retrieved January 22, 2006.
13.^ Charles Petzold (December 2001). Programming Microsoft Windows with C#. Microsoft Press.
Beyond the Console, page 47.
14.^ Charles Petzold (November 11, 1998). Programming Windows, Fifth Edition. Microsoft Press.
APIs and Memory Models, page 9.
15.^ Raymond Chen (October 15, 2003). What about BOZOSLIVEHERE and
TABTHETEXTOUTFORWIMPS? Retrieved August 27, 2005.
16.^ The Iseran Project (1996-2001). History of the Windows API. Retrieved October 7, 2005.
17.^ Nomenclature of released 64-bit versions includes Windows XP Professional x64 Edition and
x64 Editions of Windows Server 2003, Windows Vista and Windows Server 2008 on the AMD64
platform, and Windows 2000 Server Limited Edition, Windows XP 64-bit Edition, Windows
Advanced Server 2003 for Itanium and Windows 2008 Advanced Server for Itanium on the IA-
64 platform
18.^ "Windows XP Professional x64 Edition home page". Microsoft.
http://www.microsoft.com/windowsxp/64bit/.
19.^ "Microsoft 64-bit Computing Overview". Microsoft. http://www.microsoft.com/servers/64bit/.
20.^ "MSDN: Getting Ready for 64-bit Windows". Microsoft. http://msdn.microsoft.com/en-
us/library/aa384198(VS.85).aspx.

[edit] References
1. Windows application programming interface
2. Diomidis Spinellis. A critique of the Windows application programming interface.
Computer Standards & Interfaces, 20(1):1–8, November 1998. doi:10.1016/S0920-
5489(98)00012-9.
[edit] External links
Wikibooks has a book on the topic of
Windows Programming
*Marshaling with C# Pocket Reference
• Windows API Development Guide on MSDN
• Windows API Reference on MSDN
• C++ Win32 API Tutorial
• Straight C Win32 API Tutorial no MFC
• Advanced Win32 api newsgroup
• French Win32 api newsgroup
• Windows API Code Pack for Microsoft .NET Framework
• ECMA-234 - ECMA standard for a subset of the Windows API
• Windows API - Developers discussion forum - Win32 API discussion forum.
[show]
v•d•e
Microsoft APIs and frameworks

G
r
a
p Desktop Window Manager · Direct2D · Direct3D (extensions) · GDI / GDI+ · WPF ·
h Windows Color System · Windows Image Acquisition · Windows Imaging Component
i
c
s

A
u
d DirectMusic · DirectSound · DirectX plugin · XACT · Speech API
i
o

M
u
l
t
DirectX · (Media Objects · Video Acceleration) · DirectInput · DirectPlay · DirectShow ·
i
Image Mastering API · Managed DirectX · Media Foundation · XNA · Windows Media ·
m
Video for Windows
e
d
i
a

W
e MSHTML · RSS Platform · JScript · VBScript · BHO · XDR · SideBar Gadgets
b

D Data Access Components · Extensible Storage Engine · ADO.NET · ADO.NET Entity


a Framework · Sync Framework · Jet Engine · MSXML · OLE DB · OPC
t
a
a
c
c
e
s
s

N
e
t
w
o Winsock (LSP) · Winsock Kernel · Filtering Platform · Network Driver Interface
r Specification · Windows Rally · BITS · P2P API · MSMQ · MS MPI
k
i
n
g

C
o
m
m
u
n
i Messaging API · Telephony API · WCF
c
a
t
i
o
n

A Win32 console · Windows Script Host · WMI (extensions) · PowerShell · Task Scheduler ·
d Offline Files · Shadow Copy · Windows Installer · Error Reporting · Event Log · Common
m Log File System
i
n
i
s
t
r
a
t
i
o
n
a
n
d

m
a
n
a
g
e
m
e
n
t

C
o
m
p
o
n
e
n COM · COM+ · ActiveX · Distributed Component Object Model · .NET Framework
t

m
o
d
e
l

L
i
b
r
Base Class Library (BCL) · Microsoft Foundation Classes (MFC) · Active Template
a
Library (ATL) · Windows Template Library (WTL)
r
i
e
s

D Windows Driver Model · Windows Driver Foundation (KMDF · UMDF) · WDDM ·


e NDIS · UAA · Broadcast Driver Architecture · VxD
v
i
c
e
d
r
i
v
e
r
s

S
e
c
u Crypto API (CAPICOM) · Windows CardSpace · Data Protection API · Security Support
r Provider Interface (SSPI)
i
t
y

.
N ASP.NET · ADO.NET · Base Class Library (BCL) · Remoting · Silverlight · TPL ·
E WCF · WCS · WPF · WF
T

S
o
f
t
w
a
r
e
EFx Factory · Enterprise Library · Composite UI · CCF · CSF
f
a
c
t
o
r
i
e
s

I
P MSRPC · Dynamic Data Exchange (DDE) · Remoting · WCF
C

A Active Accessibility · UI Automation


c
c
e
s
s
i
b
i
l
i
t
y

T
e
x
t

a
n
d

m
u
l
t
i
DirectWrite · Text Services Framework · Text Object Model · Input method editor ·
l
Language Interface Pack · Multilingual User Interface · Uniscribe
i
n
g
u
a
l

s
u
p
p
o
r
t

[show]
v•d•e
List of Widget toolkits

L Macintosh Toolbox/Carbon · Windows API · Intrinsics · Intuition · Xlib


o
w
-
l
e
v
e
l

On Amiga OSBOOPSI · Magic User Interface · Zune · ReAction GUI

On Mac OS
Cocoa · MacApp · MacZoop · PowerPlant
and Mac OS X

Microsoft Foundation Class Library · Windows Template Library ·


On Microsoft
SmartWin++ · Object Windows Library · Visual Component Library ·
Windows
Windows Forms · Windows Presentation Foundation

On Unix,
Athena/Xaw · Motif · LessTif · InterViews
under X11

FlashAdobe Flex · Gnash · SWF2EXE Software


H
Ample SDK · CougarXML · Dojo Toolkit · Echo · Ext ·
i
GladeXML · jQuery · Lively Kernel · MooTools ·
g XML, AJAX
Pyjamas · qooxdoo · Rialto Toolkit · script.aculo.us ·
h or SVG
XAML · XML User Interface · XUL · Google Web
-
Toolkit · Yahoo! UI Library
l
e
Abstract Window Toolkit · Swing · Standard Widget
v Java
Toolkit · Qt Jambi
e
l
Cross- CEGUI · Component Library for Cross Platform · FLTK ·
platform, FOX toolkit · OpenGL User Interface Library · GTK+ ·
by language C or C++Juce · JX Application Framework · Qt · Tk · TnFOX ·
Visual Component Framework · wxWidgets · YAAF ·
XForms · XVT · Ultimate++

CAPI · Common Graphics · CLIM · McCLIM · Garnet ·


Common Lisp
Ltk

Object PascalIP Pascal · Lazarus · fpGUI

PythonPyjamas · PyQt · PyGTK · PyGUI · wxPython · PySide

Objective-CGNUstep
Retrieved from "http://en.wikipedia.org/wiki/Windows_API"
Categories: Operating system APIs | Microsoft application programming interfaces
Hidden categories: All pages needing cleanup | Wikipedia articles needing clarification from
August 2009 | All articles with unsourced statements | Articles with unsourced statements from
July 2010
Personal tools
• New features
• Log in / create account
Namespaces
• Article
• Discussion
Variants
Views
• Read
• Edit
• View history
Actions
Search
Top of Form
Special:Search

Search

Bottom of Form
Navigation
• Main page
• Contents
• Featured content
• Current events
• Random article
Interaction
• About Wikipedia
• Community portal
• Recent changes
• Contact Wikipedia
• Donate to Wikipedia
• Help
Toolbox
• What links here
• Related changes
• Upload file
• Special pages
• Permanent link
• Cite this page
Print/export
• Create a book
• Download as PDF
• Printable version
Languages
• Беларуская (тарашкевіца)
• Česky
• Dansk
• Deutsch
• Ελληνικά
• Español
• ‫فارسی‬
• Français
• 한국어
• Bahasa Indonesia
• Italiano
• Lietuvių
• Bahasa Melayu
• Nederlands
• 日本語
• Polski
• Română
• Русский
• Suomi
• Українська
• 中文
• This page was last modified on 26 August 2010 at 15:19.
• Text is available under the Creative Commons Attribution-ShareAlike License;
additional terms may apply. See Terms of Use for details.
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit
organization.
• Contact us
• Privacy policy
• About Wikipedia
• Disclaimers

Das könnte Ihnen auch gefallen