A brief introduction of COM programming Technology under Delphi

Source: Internet
Author: User
Tags object model

Component Object Models (Component object model, hereinafter referred to as COM) is a specification of the interface between component objects, and objects that follow COM interface specifications can communicate and interact with each other, even if these objects are made by different vendors, in different languages, Written and built on different versions of Windows and even on different machines. Delphi supports the COM interface specification, and the Object Pascal language adds a method to the interface of objects. COM objects created with Delphi can also work in an MTS (Microsoft Transaction Server) environment.

Software reuse is the industry's goal, people always want to be able to "assemble" the application like building blocks, the Component object acts as the role of the building blocks. The so-called Component object, in fact, is predefined good, can complete a certain function of the service or interface. The question is, how do these component objects coexist with applications, how they interact with other component objects, and communicate with each other? This requires the development of a specification for these component objects to work in a uniform and standard manner.

COM is a binary specification that is independent of the source code. In this way, even though COM objects are created by different programming languages and run in different process spaces and different operating system platforms, these objects can communicate with each other. COM is both a specification and an implementation that provides a standard interface to access the core functionality of COM objects, as well as a set of API functions, in the form of COM libraries (OLE32.dll and paste OLEAut32.dll), which are used to create and manage COM objects. COM is still essentially a client server model. The customer (usually the application) requests the creation of a COM object and manipulates the COM object through the interface of the COM object. The server creates and manages COM objects based on the customer's request. Both the customer and the server roles are not absolute.

Component objects are similar and differ from objects in general. Objects in general are instances of data types that encapsulate data and manipulate data, while component objects use interfaces (Interface) rather than methods to describe themselves and provide services. The so-called interface, whose exact definition is "a set of semantically related functions based on an object", is actually a pure virtual class, the interface object that really implements the interface (Interface object). A COM object can have only one interface, such as a wndows 95/98 shell extension, or a number of interfaces, such as an AC coffee ex control that typically has multiple interfaces, and customers can manipulate ActiveX controls in many ways. Interfaces are the only way for customers to communicate with the server. If a component object has multiple interfaces, there is no direct access to other interfaces through an interface. However, COM allows the customer to invoke QueryInterface () in the COM library to query other interfaces supported by the Component object. In this sense, the Component object is somewhat like the broker of the interface object.

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.