Home Technology A Complete Guide on Windows API

A Complete Guide on Windows API

190
0

API stands for application programming interface and in Windows, it allows the operating system to interact with user-written programs. It allows information to be displayed on the monitor of a PC. It also gets input from the computer keyboard and mouse. In addition to the console programs, all other programs must interact with windows API despite the language used. Win32 API is the latest version. An extensive library of developer help information is maintained by Microsoft at msdn. But this is not the best place to learn API basics since the presentation is often presented in a complex manner. 

If you are familiar with C or C++ in the traditional scenario of console input/output, then this is the best place to extend your knowledge and write windows applications. Although you may not have realized it, you must have come across WinAPI through Microsoft Visual C++. To get you started with windows API, this is the best developer environment. It also offers something relatively new to developers who like to use the old school console programming known as a resources file. 

With this combo, you will get an impression that you can’t use .h files and .cpp files and compiled with your favourite compiler to write your own self-contained program. This is just a perception and a false impression. This doesn’t mean that the resources are not useful. You can proceed without it at the beginning and once you are comfortable with it, you can bring it later.

This guide was created and Windows 7 was used to test it. We have built the examples using the Pelles C compiler. Downloading and installing this compiler is necessary if you are going to read this tutorial. Don’t worry, this is a freeware and you won’t be charged to download it. You can use another compiler, but you have to ensure that it supports the C99 standard.

The Windows API is the application programming interface for creating Windows applications. Before creating Windows applications, downloading Windows SDK is necessary. Previously, it was called Platform SDK. SDK stands for software development kit and it has samples, libraries, header files, tools and documentation that are used by the Windows API to develop applications. 

Designed for C and C++ programming languages, the Windows API is the most straightforward method for creating Windows applications. There are several parts in which the Windows API is divided into:

  • Security
  • Base services
  • User interface
  • Graphics
  • Multimedia
  • Networking
  • Windows shell

On Windows, access to the fundamental resources are provided by Base services. These include processes, devices, file systems, threads, error or registry handling. Security related tasks such as authorization, authentication, cryptography are provided by interfaces, objects, functions, and other programming elements. 

Outputting functionality graphical content to monitors is provided by the Graphics subsystem. These include content to printers, monitors, and other output devices. The functions for creating control and windows are provided by the user interface. Tools for video, sound and input devices are provided by the Multimedia component.

The operating system shell provides the functions for Windows shell interface that allows applications to access the functionality. Network capabilities access to the Windows OS are provided by the Network. Windows API consists of declarations of structures, macros, functions, unions, data types, constants and other programming elements. Windows API resides in the Windows C headers and is described mainly by the MSDN (Microsoft Developer Network). In the dynamic libraries (DLLs) is where the official implementation of the Windows API functions is found. For instance kernel32.dll, user32.dll, gdi32.dll, or shell32.dll in the Windows system directory.

The ReactOS project and the Wine project are some of the third-party implementations of Windows API. It is a dynamic entity. With every new version of Windows operating system and new service packages, the number of functions keeps growing. Critical differences between the desktop versions and the server versions of the OS also exist. Officially, some functions are not yet documented. 

Pelles C

Pelles C is also an integrated development environment (IDE) for the C programming language, besides being an ideal C compiler. Pelles C also supports 32-bit Windows (x86) and 64-bit Windows (x64). Both C99 and C11 standards are implemented by this IDE. This compiler comes with a bitmap, an integrated resource editor, a hex-dump editor, and icon and cursor editor. A Swedish developer called Pelle Orinius is the brains behind this compiler. You can use it to create Windows applications instantly since it comes with Windows SDK without further installations. 

To create Windows API programs, you will have to enable Microsoft extensions. By default, they are not enabled. Therefore, this error message will be shown by the compiler: fatal error #1014: #error: “No target architecture”. You will have to head over to the project options and click on the Compiler to enable Microsoft extensions. 

Conclusion 

The Windows API provides the best environment to create Windows apps. If you want to develop applications for the Windows operating system then Windows application programming interface will allow you to do it seamlessly. Pelles C compiler is the best when using Windows API. However, you can use it with other compilers provided they can support the C99 standard.