Joke Collection Website - Blessing messages - What does api interface mean? How?

What does api interface mean? How?

API (Application Programming Interface) is a set of predefined Windows functions that control the appearance and behavior of various Windows components (from the appearance of the desktop to the memory allocated for new processes). Every action of the user will trigger the operation of one or several functions and tell Windows what happened.

To some extent, this is very similar to the natural code of Windows. Other languages only provide an automatic and convenient way to access the API. VB has done a lot of work in this field. It completely hides the API and provides a completely different programming method in the Windows environment. In other words, every line of code you write in VB will be converted into API function by VB and passed to Windows. For example, Form 1. Print ... VB will call the API function TextOut with certain parameters (provided in your code or default parameters). Similarly, when you click a button on the form, Windows will send a message to the form (hidden from you), and VB will get this call, which will generate a specific event (Button_Click) after analysis.

API functions are contained in dynamic link library files under Windows system directory (such as user32.dll, gdi32.dll, shell32.dll ...).

API declaration

As described in "What is API", API functions are contained in a DLL file located in the system directory. You can enter the declaration of API function yourself, but VB provides an easier way, which is to use the API text viewer. To declare API functions in a project, just run the API text viewer. Open Win32api.txt (or. MDB, if you convert it into a database, you can speed it up. Note: this file of Microsoft has many shortcomings. You can try api32.txt downloaded from this site, select "Declaration", find the required function, click "Add" and "Copy", and then paste it.

You will encounter some problems:

Suppose you want to declare a function in a form module. Paste and run it. VB will tell you: compilation error ... declare statement is not allowed as a public member in a class or object module ... it looks bad. In fact, all you need to do is add a private (such as a private declare function ...) before the declaration. -However, don't forget that this will make this feature available only in the form module. In some cases, you will get the prompt of "ambiguous name" because a function, constant or other * * * uses a name. Because most functions (or maybe all of them, which I haven't verified) are aliases, this means that you can use other names instead of their original names through the alias clause, and you just need to simply change them.

Apis are divided into four types:

Remote Procedure Call (RPC): The communication between programs is realized by the process (or task) that acts on the data buffer.

Standard Query Language (SQL): It is a standard query language for accessing data, and data sharing between applications is realized through a general database.

File transfer: file transfer realizes data sharing between applications by sending formatted files.

Information delivery: refers to small formatted information between loosely coupled or tightly coupled applications, and realizes data sharing through direct communication between programs.

At present, the standards applied to API include ANSI standard SQL API. In addition, some standards applicable to other types are still being worked out. API can be applied to all computer platforms and operating systems. These APIs connect data in different formats (such as data buffers, database structures and file frames). Each data format requires different data commands and parameters to achieve correct data communication, but it also produces different types of errors. Therefore, in addition to the knowledge needed to perform data sharing tasks, these types of APIs must also solve many network parameter problems and possible error conditions, that is, each application must know whether it has strong performance to support inter-program communication. On the contrary, because this API only deals with one information format, the information delivery API in this case only provides a small subset of commands, network parameters and error conditions. Because of this, the delivery API greatly reduces the complexity of the system, so when the application needs to share data across multiple platforms, it is an ideal choice to adopt the information delivery API type.

There are obvious differences between API and graphical user interface (GUI) or command interface:

API interface belongs to operating system or program interface, and the latter two are direct user interfaces. Sometimes companies use API as their public open system. In other words, the company formulates its own system interface standard, and all members of the company can call the source code through this interface standard when they need to do system integration, customization, program application and other operations. This interface standard is called open API.