Study Notes on the principle and application of COM

Source: Internet
Author: User

To learn how to compile ActiveX plug-ins, we have learned the principles of COM over the past few days. ActiveX is based on COM. Therefore, to learn more deeply about ActiveX technology, you must first learn the principle of COM.

Com is a component standard proposed by Microsoft. Com is generated during the development of OLE technology. Ole mainly implements composite documents, and ole1 only implements the composite document function. ole1 uses a technology called Dynamic Data Exchange (DDE. The DDE technology is based on messages in windows, which has the disadvantages of poor stability and low efficiency. Therefore, DDE was quickly eliminated. In ole2, the second version of OLE, Microsoft rewritten a large number of underlying OLE Code and launched a new COM model. (The above content is taken from "com Principles and Applications", P10)

Com includes two parts: one is the COM specification, and the other is the environment required to provide component program running. The COM component can be regarded as a module, which can enable the dynamic link library (DLL) or an executable file. In addition, the implementation of COM is in binary code, and there is no situation where different languages cannot be called, so you can call it in exaggerated languages. Currently, most languages Support com, and mainstream languages such as C ++ and Java support COM.

Advantage of COM: When I first looked at com, I came up with such a problem. To use the functions provided by other components, you need to use a lot of repeated and troublesome functions to load the components. Isn't that very troublesome? Why don't you use DLL to solve the problem directly. Later I thought about the advantages of using COM. DLL needs to be loaded into the process, while com can provide external calls, or even call components on a remote computer. At the same time, after the DLL is loaded into the process, once the function in the DLL crashes, the main process will also crash. If this is an out-of-process call, the main process can still run stably.

In the face of a large program with many functions, we will naturally think of dividing these functions into several small pieces for implementation. This facilitates development, testing, and maintenance. These small modules are components. Com is an object-oriented component model that supports inheritance and Data encapsulation. COM components are implemented based on COM specifications. The COM object is a collection of some functions, all of which are in an abstract class (here is my understanding, you are welcome to make a brick ). The COM interface is something that the COM object is used to provide services (it is worth noting that the COM interface is a set of interfaces used to provide a class of complete services ). A com component can contain multiple COM objects. a com object can also contain multiple com interfaces. As shown in:

In the next article, I will make a small practical example. At present, this example is a little problematic and has not been completed yet ~

 

Study Notes on the principle and application 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.