zoukankan      html  css  js  c++  java
  • 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?

    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.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.

    作者:Angelo Lee
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    刷脸背后:人脸检测人脸识别人脸检索_张重生资料整理
    webpack工具
    js精度缺失和最大安全整数
    在线文档预览(干货篇)
    讨论js比较两个数组(对象)是否相等的范围
    js不同数据类型中==与===的对比
    js中this的指向
    前后端数据类型
    js网页节点操作
    圆角渐变边框实现
  • 原文地址:https://www.cnblogs.com/yefengmeander/p/2889690.html
Copyright © 2011-2022 走看看