What is DLL and Lib?

DLLs in Visual C++

http://msdn.microsoft.com/en-us/library/1ez7dh12.aspx

A dynamic-link library (DLL) is an executable file that acts as a shared library of functions. Dynamic linking provides a way for a process to call a function that is not part of its executable code. Multiple applications can simultaneously access the contents of a single copy of a DLL in memory.

Dynamic linking differs from static linking in that it allows an executable module (either a .dll or .exe file) to include only the information needed at run time to locate the executable code for a DLL function. In static linking, the linker gets all of the referenced functions from the static link library and places it with your code into your executable.

Differences Between Applications and DLLs

Even though DLLs and applications are both executable program modules, they differ in several ways. To the end user, the most obvious difference is that DLLs are not programs that can be directly executed. From the system's point of view, there are two fundamental differences between applications and DLLs:

  • An application can have multiple instances of itself running in the system simultaneously, whereas a DLL can have only one instance.

  • An application can own things such as a stack, global memory, file handles, and a message queue, but a DLL cannot.

Kinds of DLLs

If your DLL is using MFC, Visual C++ supports three different DLL development scenarios:

  • Building a regular DLL that statically links MFC

  • Building a regular DLL that dynamically links MFC

  • Building an MFC extension DLL, which always dynamically link MFC

Non-MFC DLLs: Overview

Regular DLLs statically linked to MFC

Regular DLLs dynamically linked to MFC

Extension DLLs: Overview

What is Extension DLLs?

An MFC extension DLL is a DLL that typically implements reusable classes derived from existing Microsoft Foundation Class Library classes. Extension DLLs are built using the dynamic-link library version of MFC (also known as the shared version of MFC). Only MFC executables (either applications or regular DLLs) that are built with the shared version of MFC can use an extension DLL. With an extension DLL, you can derive new custom classes from MFC and then offer this extended version of MFC to applications that call your DLL.

What is the difference between Extension DLL and Regular DLL?

 
 

Initializing a DLL

http://msdn.microsoft.com/en-us/library/7h0a8139.aspx

Importing and Exporting

http://msdn.microsoft.com/en-us/library/9h658af8.aspx

You can import public symbols into an application or export functions from a DLL using two methods:

  • Use a module definition (.def) file when building the DLL

  • Use the keywords __declspec(dllimport) or __declspec(dllexport) in a function definition in the main application

Linking an Executable to a DLL

An executable file links to (or loads) a DLL in one of two ways:

Search Path Used by Windows to Locate a DLL

With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then searches for the DLLs in the following sequence:

  1. The directory where the executable module for the current process is located.

  2. The current directory.

  3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

  4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

  5. The directories listed in the PATH environment variable.

转载于:https://www.cnblogs.com/yefengmeander/archive/2013/02/02/2889690.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值