What's New!!!
Tutorials added for learning basics of C++ window programming.
What is Windows API?
Overview
IN MY OWN WORDS
What is Windows API?
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to a number of different platform implementations that are often referred to by their own names (for example, Win32 API); see the versions section. Almost all Windows programs interact with the Windows API; on the Windows NT line of operating systems, a small number (such as programs started early in the Windows startup process) use the Native API.
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, processes, 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 additional to 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. - User Interface
- 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
- 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
- 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 DLLfile 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. This component resides in netapi32.dll on 32-bit Windows.
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.
IN MY OWN WORDS
The Windows API (application programming interface) allows user-written programs to interact with Windows, for example to display things on screen and get input from mouse and keyboard. All Windows programs except console programs must interact with the Windows API regardless of the language. The most recent version (as of 2007) is Win32 API. Microsoft maintains an extensive library of developer help information at msdn, but the presentation is often hard to follow and I would say this is not a good place to learn the basics.
This tutorial is intended for people reasonably familiar with C or C++ in the traditional scenario of console input/output , and who now want to write windows applications.
I first met WinAPI (without knowing that is what I was meeting) through microsoft Visual C++. That developer environment provides a bunch of code to get you started, as well as something called a resources file which is new to programmers used to old-style console programming. This combination gives the user the distinct impression that you can no longer write your own self-contained program made purely of .h files and .cpp files and compiled with your favourite compiler. However, that is a false impression. Although the resources file is useful, my advice is to get started without it, and then bring it in once you are comfortable.
A further reservation I have about MSVC++, is that it makes it very difficult to edit the resources manually, or bring them in from other code. It is well-supported however, and excellent in many ways, so you may want to use it if you have the money. I have compiled a few notes on issues I have met with Visual C++ in hopes that they may help someone. I have also used a rather nice free developer environment for C++ on Windows called Dev-Cpp from Bloodshed software (don't worry about the odd name: the software is good). Another well-supported free developer environment is CodeBlocks.