Com Study Notes (1)

Source: Internet
Author: User

Recently, due to project needs and access to COM technology that has never been thoroughly understood, I decided to calm down and study it well. Let's get started with COM.

COM (Component Object Model) is a component standard proposed by Microsoft. In the com standard, a componentProgramIt is also called a module. It can be a DLL, called an in-process component, or an EXE, called an out-of-process component. Com is a model with objects as the basic unit. A component program can contain one or more component objects. Communication between programs depends on component objects, component programs (COM programs) provide Component Objects (COM objects ).CodeCarrier.

The COM object is different from the object concept in general object-oriented languages (such as C ++). The COM object is based on binary executable code, c ++ and other language objects are created inSource codeTherefore, the COM object is language independent. This feature makes differentProgramming LanguageIt is possible to develop component objects for interaction.

The proposal of components promotes software development and makes software upgrade more flexible. When the system's external software and hardware environment changes or the user's needs change, you do not need to modify all components, but only need to modify the affected components, then you can combine the software to get the new software upgrade. Communication between components is actually implemented through interfaces. Therefore, in this sense, Com also provides interface standards between components. The relationship between COM components, COM objects, and COM interfaces is shown in Figure 1.1.

Figure 1.1 Relations between COM components, COM objects, and COM Interfaces

When another component or common client program calls the component function, it first creates a COM object or obtains the COM object through other means, then, call the services provided by the object through the COM interface implemented by the object. After all services are completed, if the client program does not need the COM object, it should release the resources occupied by the object, including the object itself.

In the com model, the object itself is invisible to the customer program. When the customer requests the service, it can only be performed through the interface. An interface is actually a set of logically related functions. Its functions are also called interface member functions. Each interface is identified by a 128-bit guid. The customer program obtains the interface pointer through the guid, and then calls its corresponding member functions through the interface pointer. As for the implementation of specific functions, it is completely implemented inside the interface of the object. Therefore, for a client program, it only needs to care about how to communicate with the interface, and does not need to care about the internal implementation of the interface.

Similar to interfaces, each object is identified by a 128-bit guid and becomes a CLSID (Class Identifier ). The client program can use CLSID to create a COM Object. At the same time, it can obtain a pointer to an interface of the object (each COM Object implements at least one interface, COM objects without interfaces are meaningless. Therefore, the client program can call the services provided by interfaces. According to the COM specification, if a COM Object implements multiple interfaces, any other interfaces of the object can be obtained from an interface.

This is the most basic concept of COM. You are welcome to discuss it together.

Related Article

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.