开发者

difference between API and DLL

开发者 https://www.devze.com 2023-01-29 15:04 出处:网络
I would like to kn开发者_开发知识库ow the exact differences between API and DLL. Thank you.Pretty much the only connection between the two terms is that if you do native Windows programming, APIs you

I would like to kn开发者_开发知识库ow the exact differences between API and DLL. Thank you.


Pretty much the only connection between the two terms is that if you do native Windows programming, APIs you use or write will usually manifest as DLL files. But neither is this the only concrete form an API can take, nor does every DLL represent an API.

API means "Application Programming Interface" - it's an abstract term for a collection of code entities (functions, classes, etc. - depends on the programming language) that's intended to be used by programmers at large to access the functionality of an application or library.

A DLL is a file format on Windows that contains executable code as a way to modularize applications.


A DLL is a library of code, and API is an interface to a library of code.


An application programming interface (API) is an interface implemented by a software program that enables it to interact with other software. It facilitates interaction between different software programs similar to the way the user interface facilitates interaction between humans and computers. - Wikipedia

A Dynamic Link Library (DLL) is a one way of providing an API. (Interface to the programmer) You may have various other methods, like Web services.


DLL = Dynamic-link library

API = Application programming interface

A DLL is just a file on Windows systems that has some code in that can be used by other executable files. An API is a way of using one piece of software, or a software library, to be used with another. For example there is a Windows Registry API that allows you to use the registry, but the code that runs when you use the API is stored in a DLL.


Updates: DLL (Dynamic Link Library) is a code component (some what like the Beans in Java). DLLs contains the methods or functions or routines or whatever you call those code fragments. And an API is an interface between an application and that DLL. Most of the time DLLs are used to provide services to other applications, these DLLs are called Server DLLs and if a DLL is requesting some service by using the API call or its dynamic invocation then it is said to be the Client DLL. So simple think, APIs are nothing but the methods or functions which are accessible from outside of that DLL. Hope you got the idea now.


API are the header files (.h) which contain function and class declarations (input and output parameters), the implementation of these declaration i.e definitions of class or functions will be in particular dlls.

But to connect (dynamic linking) both these .h and .dll files, you require .lib files, these files will resolve the address of function definition during run-time and that particular dll files are loaded. Hence, libraries contain (APIs(.h), lib and dll files).

APIs make application development independent of underlying library implementations.

Example:

if you write a program in C to print "Hello World". And if you run the same program in windows and Linux.

Both these executable will use different system libraries to display it on screen, as C language provides set of APIs like "STDIO.h","STDLIB.h", You need not worry about the underlying library implementations.

So you can think, API as header files, which connect function/class declarations with function/class definitions. Hence, the name "Application program interface".


You will have to be specific. DLL can stand for:

  1. Data Link Layer,
  2. Dynamic Link Library (Shared library on Windows Platform). It can also be a resource library too.

An API (Application Programming Interface) is an interface that's implemented by software programs to interact with other sotware. E.g. JDBC api is needed if a database connection is required in java.

From Wikipedia:

An API is implemented by applications, libraries, and operating systems to determine their vocabularies and calling conventions, and is used to access their services.

The purpose of a DLL (Dynamic libraries almost always offer some form of sharing, allowing the same library to be used by multiple programs at the same time). In essence, the WINAPI (Windows API) are all implemented in DLL files, such as mmsystem.dll for MMSYSTEM Sound API.

References:

  • API
  • DLL


An API is an interface for communication of different components of an application, where dll is a library file which contains code so that your program can use using your API


Every DLL has some (is an?) interface (API) because otherwise it would be useless, but not every API is a DLL as in example You can have Web Api where You are using remote endpoints using in example HTTP protocol - not even a file like in DLL case


A simplified answer.

API is always (by definition) an application programming interface. It's a collection of methods that can be used as an interface to an app, a web service, etc.

DLL is a shared library file of the same format as executable. It contains code and data to be shared between other EXEs so you don't have to recompile them every time a DLL is updated. DLLs, for example, allow you upgrade Windows versions and keep the applications running on the latest version. It may contain code that's reusable by one or more executables, like an API. One the other hand, it may contain only data, like icons (.icl) and fonts (.fon).

0

精彩评论

暂无评论...
验证码 换一张
取 消