What is DLL and Lib?
2013-02-02 00:00
281 查看
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.
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?
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
Implicit linking
Explicit linking
The directory where the executable module for the current process is located.
The current directory.
The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
The directories listed in the PATH environment variable.
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?
1. Extension DLL only used in MFC applications while Regular DLL used in MFC and non - MFC applications. 2. Extension DLL are not derived from CWinAppl classes while Regular DLL is derived from CWinApp class. 3. Extension DLL can export function and classes while in the case of Regular DLL can export only functions.
Initializing a DLL
http://msdn.microsoft.com/en-us/library/7h0a8139.aspxImporting and Exporting
http://msdn.microsoft.com/en-us/library/9h658af8.aspxYou 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:Implicit linking
Explicit linking
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:The directory where the executable module for the current process is located.
The current directory.
The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
The directories listed in the PATH environment variable.
相关文章推荐
- Under The Hood: Reduce EXE and DLL Size with LIBCTINY.LIB
- lib and dll
- Reduce EXE and DLL Size with LIBCTINY.LIB
- How to call DLL and LIB files (SDK)
- Window DLL and LIB export
- Reduce EXE and DLL Size with LIBCTINY.LIB figure
- [under the hood]Reduce EXE and DLL Size with LIBCTINY.LIB
- 【转】XZip and XUnzip - Add zip and/or unzip to your app with no extra .lib or .dll
- Difference between .DLL And .LIB
- Reduce EXE and DLL Size with LIBCTINY.LIB
- lib and dll
- Generate .lib from .dll and .def
- How to make dll and lib using bakefile.
- Reduce EXE and DLL Size with LIBCTINY.LIB
- LIB/DLL/CRT//MD, /MT, /LD and more under Windows
- LIB and DLL
- How to create .lib file when you only have .dll and .h files
- 每次使用都要去Google的基础知识--.lib与.dll
- 款通用SSK皮肤的使用【通过使用.h lib dll文件】