Static Connection Library, dynamic connection library, and COM component (zz)

Source: Internet
Author: User

Differences:

(1) Static Connection Library as the targetCodeIs linked

(2) the dynamic Connection Library and the target code are two parts.

(3) The COM component is called by registering the location and interface of the dynamic library in the registry.

Advantages and disadvantages:

(1) Static disadvantage: Make the targetProgramIncreased volume, not flexible
(2) Advantages of Dynamic Link Library: to modularize the program, as long as the interface function remains unchanged, changing the details of the DLL's internal implementation will not cause call failure, but cannot solve problems such as reference count.
(3) com solves some problems that cannot be solved by DLL.

Differences between DLL and COM:

 

Com is the Component Object Model (Component Object Model), which is the standard for Microsoft production software components. It is a specification for building Binary compatible software components, regardless of the language of the component application, as long as the COM specification can be followed to communicate with each other directly. The COM specification is proposed to meet the following requirements:
1. Rapid program development: a large project can be divided into multiple COM components for simultaneous development.
2. You can dynamically insert or uninstall COM components.
3. You can hide or encapsulate the implementation details inside the COM component. COM components can be compiled in different languages, but communication between COM components is achieved through component interfaces, and the implementation of COM component interfaces is unified, it adopts the virtual function table (vtbl) form. The virtual function table contains a set of pointers for component functions. We can use these pointers to obtain the memory address of the component functions we want to communicate.
DLL (Dynamic Link Library) is a set of modules that contain functions and data. It can export data or function for other DLL calls. DLL loading can be done through static link and dynamic link.
1. Compile the DLL module to be linked to another module in binary format during static link.
2. dynamic Link refers to calling the module to load the DLL at runtime, using the loadlibrary function or LoadLibraryEx function to load the DLL to the address space of the process, and calling the getprocaddress function to obtain the address of the exported DLL function.
Advantages of dynamic DLL loading:
1. dll can save memory and reduce swap. By sharing a single copy of the DLL in the memory, multiple processes can use one DLL at the same time. In contrast, for every application built using a static Linked Library, windows must load a copy of the library code for it in memory.
2. dll can save disk space. Multiple applications can share one DLL copy on the disk. In contrast, every application built using a static Link Library requires the library code linked to the program file image as a separate dedicated copy.
The relationship between DLL and COM: COM is a specification. dll implemented according to the COM specification can be considered as a COM component, for example, the interface encapsulation in the Active X control project established by MFC is described by IDL, so it can be regarded as a COM component. In addition, we can see from the above description about com and DLL that the COM Component Interface is a set of functions with specific specifications. Therefore, the COM component can be regarded as a DLL, but the DLL is not necessarily a COM component.
The biggest difference between COM and DLL is that DLL is called in the form of a function set Programming Language The related image VC must contain extern "C "... com provides users with a binary call specification in the form of interfaces, which is irrelevant to programming languages, it uses the IDL Interface Definition Language to describe its own use of class inheritance to implement its own functions and methods. DLL only has one situation of DLL, which can define any function without restrictions. It can only run on the local machine, while COM has two situations: DLL and exe. The DLL where COM is located must export four functions:
Dllgetobjectclass, dllregisterserver, dllunregisterserver, dllunloadnow
These four functions have their own functions, some of which are provided for the com manager, used through CLSID and IID, and some for the registration machine.
Com, combined with MTS, is the advanced version of COM +. It provides a more powerful and Secure Distributed COM Service, DCOM runs on different machines and uses proxy and stub to implement local ing of remote interfaces. The two are similar in execution speed, but the start speed of DLL is faster than that of COM.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.