COM component Introduction

Source: Internet
Author: User

The object-oriented idea is difficult to adapt to this distributed software model, so the idea of componentized programming has developed rapidly. According to the idea of componentized programming, complex applications are designed into small, single-functional component modules that can run on the same machine, it can also run on different machines. In order to implement such an application, some extremely detailed specifications are required between the build program and the build program. Only when the component program complies with these common specifications can the system operate normally. Therefore, OMG and Microsoft proposed the Common Object Request Breaker Architecture and COM (Component Object model) standards respectively. Currently, the CORBA model is mainly used on UNIX operating system platforms, COM is mainly used on the Microsoft Windows operating system platform.

COM concept:

COM is a specification that describes how to establish dynamically changeable components. It provides some standards that customers and components should follow to ensure the interoperability of the producer. The COM specification is a set of documents that set standards for the component architecture. COM is not a computer language. COM describes how to write components. However, it is free to use a descriptive language.

COM component concept:

The COM component is composed of executable code published in the form of win32 Dll or exe, which is a few small binary executable files. COM components are written in accordance with the COM specification. The COM component is not a DLL, but a DLL is used to provide dynamic links to the component. In fact, the best way to use Dll dynamic link capability is COM. Any problems solved by Dll can be better solved by using COM components.

Requirements for COM components:

1. components must be dynamically linked.

2. Hide its internal implementation details. If an application or component uses other components, we call it a customer who connects to other components through interfaces. If the interface remains unchanged, the communication between the customer and the component remains unchanged. Information encapsulation means that the component and the customer's internal implementation details cannot be reflected in the interface. To isolate the customer from the component, you must add some restrictions on the component.

1) components must encapsulate the programming language used for their implementation. In a language-independent architecture, components can be written by anyone, and these components are not outdated due to the development of programming languages. This architecture will greatly promote the prosperity of the software market.

2) The component must be released in binary format.

3) components must be upgraded without interfering with existing users. This backward compatibility capability is required by components. A group will be upgraded to adapt to the needs of new applications, while enabling it to support old applications.

4) the COM component can be transparently assigned a location on the network.

Advantages of using components:

1) applications can evolve over time, that is, using components makes upgrading existing applications more convenient and flexible. Such as application customization.

2) Rapid Application Development. This advantage allows developers to extract the required components from a component library and quickly assemble them into one to construct applications, just like building blocks.

3) Simplify distributed application development.

COM basic terms

1. interface: an interface can be seen as a group of functions called methods. The interface name starts with "I", such as "IShellLink". In C ++, an interface is an abstract base class that only contains pure virtual functions.

2. coclass: Abbreviation of component object class. Coclass is used to implement interfaces. A com object is an instance of coclass in memory ). Note that COM "class" and C ++ "class" are not one thing, although the implementation of COM class is usually C ++ class.

3. COM Server: contains one or more coclass binary modules (DLL or EXE ).

4. Registry: register with Windows and register the location and portal of COM Server. Unregistry is the opposite process: Remove this registration from Windows.

5. GUID: globally unique identifier. The number of 128 bits. COM uses a language-independent GUID as the identifier. Each interface and coclass have a GUID, because GUID is unique across the world. This avoids name conflicts. Sometimes GUID is also called UUID (universally unique identifier ). The class ID of a coclass is called CLSID, And the interfaceID of an interface is called IID.

6. HRESULT: an integer value that is used by COM to return success or error code. You can use the Windows Error Code query to obtain the characters in HRESULT.

 


References:

COM technology insider

 

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.