DLL 文件究竟是什么,它们是如何工作的? [英] What exactly are DLL files, and how do they work?

查看:50
本文介绍了DLL 文件究竟是什么,它们是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DLL 文件究竟是如何工作的?它们似乎有很多,但我不知道它们是什么或它们如何工作.

How exactly do DLL files work? There seems to be an awful lot of them, but I don't know what they are or how they work.

那么,他们怎么办?

推荐答案

什么是 DLL?

动态链接库 (DLL) 类似于 EXE,但它们不能直接执行.它们类似于 Linux/Unix 中的 .so 文件.也就是说,DLL 是 MS 对共享库的实现.

Dynamic Link Libraries (DLL)s are like EXEs but they are not directly executable. They are similar to .so files in Linux/Unix. That is to say, DLLs are MS's implementation of shared libraries.

DLL 与 EXE 非常相似,以至于文件格式本身是相同的.EXE 和 DLL 均基于可移植可执行 (PE) 文件格式.DLL 还可以包含 COM 组件和 .NET 库.

DLLs are so much like an EXE that the file format itself is the same. Both EXE and DLLs are based on the Portable Executable (PE) file format. DLLs can also contain COM components and .NET libraries.

DLL 包含什么?

DLL 包含 EXE 或其他 DLL 使用的函数、类、变量、UI 和资源(例如图标、图像、文件等).

A DLL contains functions, classes, variables, UIs and resources (such as icons, images, files, ...) that an EXE, or other DLL uses.

图书馆类型:

几乎在所有操作系统上,都有两种类型的库.静态库和动态库.在 Windows 中,文件扩展名如下:静态库 (.lib) 和动态库 (.dll).主要区别在于静态库在编译时链接到可执行文件;而动态链接库直到运行时才链接.

On virtually all operating systems, there are 2 types of libraries. Static libraries and dynamic libraries. In windows the file extensions are as follows: Static libraries (.lib) and dynamic libraries (.dll). The main difference is that static libraries are linked to the executable at compile time; whereas dynamic linked libraries are not linked until run-time.

更多关于静态和动态库:

您通常不会在计算机上看到静态库,因为静态库直接嵌入在模块(EXE 或 DLL)中.动态库是一个独立的文件.

You don't normally see static libraries though on your computer, because a static library is embedded directly inside of a module (EXE or DLL). A dynamic library is a stand-alone file.

DLL 可以随时更改,并且仅在 EXE 显式加载 DLL 时才在运行时加载.静态库一旦在 EXE 中编译就不能更改.DLL 可以单独更新,而无需更新 EXE 本身.

A DLL can be changed at any time and is only loaded at runtime when an EXE explicitly loads the DLL. A static library cannot be changed once it is compiled within the EXE. A DLL can be updated individually without updating the EXE itself.

加载 DLL:

程序在启动时通过 Win32 API LoadLibrary 加载 DLL,或者当它是另一个 DLL 的依赖项时.程序使用 GetProcAddress 加载函数或使用 LoadResource 加载资源.

A program loads a DLL at startup, via the Win32 API LoadLibrary, or when it is a dependency of another DLL. A program uses the GetProcAddress to load a function or LoadResource to load a resource.

进一步阅读:

请查看 MSDN维基百科 以供进一步阅读.也是这个答案的来源.

Please check MSDN or Wikipedia for further reading. Also the sources of this answer.

这篇关于DLL 文件究竟是什么,它们是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆