Home technology Application programming interface

Application programming interface



Introduction

The application program interface is: "The code used by the ‘Operating system’ or ‘library’ for application calls." Its main purpose is to allow application developers to call a set of routine functions without having to consider the underlying source code or understanding the details of its internal working mechanism. The API itself is abstract, it only defines an interface, and does not involve the specific operation of the application in the actual implementation process.

For example, a set of APIs in the graphics library defines the way to draw the pointer, which can be displayed on the graphics output device. When the application program needs the pointer function, it can be linked to this group of APIs at the time of reference and compilation, and the implementation (library) of this API will be called to display the pointer at runtime.

The application program interface is a group of thousands of extremely complex functions and subroutines, allowing programmers to do many tasks, such as "reading files", "displaying menus", and "in windows Show web pages" and so on. The operating system's API can be used to allocate memory or read files. Many system applications are implemented through API interfaces, such as graphics systems, databases, network Web services, and even online games.

The application program interface has many different designs. Interfaces used for fast execution usually include functions, constants, variables, and data structures. There are also other ways, such as through an interpreter, or providing an abstraction layer to shield information related to the implementation of the API, to ensure that the code that uses the API does not need to be changed to adapt to the implementation change.

The application program interface is often part of the software development kit (SDK).

Purpose

A reference implementation of an API is the implementation created by the designer of the API, or one which other implementations of the API are expected to be compared against.

For example, a set of APIs in the graphics library define the way to call the drawing icon function to display the icon on the screen. Called in the program, connected to this group of APIs when compiling, and calling the implementation (library) of the API to display the icon when executing.

The operating system's API can be used to allocate memory or access files. Many systems and applications provide API interfaces and implementations, such as graphics systems, databases, networks, Web services, and even certain games.

A set of APIs is often part of a software development kit (SDK). SDK can also include other tools or hardware, the two terms are not completely equivalent.

API has many different designs. Interfaces for fast execution usually include functions, constants, variables, and data structures. There are also other ways, such as through an interpreter, or providing an abstraction layer to hide information related to the implementation of the API, to ensure that the code that uses the API does not need to be changed to adapt to the implementation change.

API is an application programming interface. It is a set of functions that can be used to manipulate components, applications, or operating systems. Typically, the API consists of one or more DLLs that provide a certain special function.

A DLL is a file that contains functions that can be called by any application running under Microsoft® Windows®. At runtime, the function in the DLL is dynamically linked to the application that calls it. No matter how many applications call a function in the DLL, only one file on the disk contains the function, and the DLL is created only when it is loaded into memory.

The API you hear most is probably the Windows API, which includes the various DLLs that make up the Windows operating system. Every Windows application directly or indirectly interacts with the Windows API. The Windows API ensures that all applications running under Windows behave in the same way.

Note

With the development of the Windows operating system, several versions of the Windows API have been released. Windows 3.1 uses Win16 API. The Microsoft® Windows NT®, Windows 95, and Windows 98 platforms use the Microsoft® Win32® API.

In addition to the Windows API, some other APIs have also been released. For example, the Mail Application Programming Interface (MAPI) is a set of DLLs that can be used to write e-mail applications.

API is traditionally written for C and C++ programmers who develop Windows applications, but other programming languages ​​(including VBA) can also call functions in DLLs. Because most DLLs are mainly written and organized for C and C++ programmers, the method of calling DLL functions is different from calling VBA functions. When using the API, you must understand how to pass parameters to the DLL function.

Warning Calling Windows API and other DLL functions may have adverse effects on your application. When calling DLL functions directly from your own code, you bypass some of the security mechanisms that VBA usually provides. If an error occurs when defining or calling a DLL function (which is unavoidable for all programmers), it may cause an application error in the application (also known as a general protection fault, or GPF). The best solution is to save the project before running the code and make sure to understand the principle of DLL function calls.

This article is from the network, does not represent the position of this station. Please indicate the origin of reprint
TOP