COM principle and application----unified data transmission

Source: Internet
Author: User

1. Overview

COM provides a standard solution for data interchange between applications, known as unified data transfer (Udt,uniform data transfer). Unified data transmission technology based on structured storage technology, it through a "data object" to express the data to be transmitted, therefore, the core of the unified data transmission technology is the definition and implementation of the object. Clipboard and drag-and-drop are two typical applications for unified data transmission.

2. Data Exchange Standard

The earlier versions of OLE1.0 used DDE (Dynamic data exchange, live Exchange) as the data exchange standard, but DDE uses a simpler format and can only use global memory as a transport medium, so the efficiency and functionality of the transmission is limited. The OLE2.0 version introduces COM as its basic structure model and uses the unified data transmission provided by COM as its exchange mechanism, which can transmit directly between different media.

3, data exchange and transmission protocol separation

The data transmission operation between different applications includes two aspects, first, the unification of the format, followed by the establishment of the transmission protocol.

Previously used DDE method can only use simple data structure to describe the information, COM's unified data transmission mechanism using "data object" as an information entity, data objects through the IDataObject interface to expose their internal information. Because the data object itself is a COM object, it can express not only the general structured information, but also some unstructured information, even dynamic information. The IDataObject interface establishes the standard for data transfer by applications. On Windows platforms, the most basic transport protocols are clipboard, drag-and-drop, and applications typically use both protocols to get data objects.

Before the unified data mechanism was introduced to the Windows system, Windows provided many API functions and predefined messages for the bridge between applications to transmit data. These API functions bind transport protocols and transmit data information, such as a set of functions for processing clipboard data transfer: GetClipboardData, SetClipboardData, and CloseClipboard, DDE, by sending a message, is used as a means of transmitting data.

The unified data transmission mechanism provided by COM can well avoid the restriction of data transfer of Windows API function, on the one hand it defines two data structure FORMATETC and stgmedium, which are used to describe data format and storage medium respectively, Enables the new mechanism to adapt to a wider range of data types and storage media, and on the other hand it provides a mechanism for data-table notifications.

The concept of data object makes the unified data transmission mechanism not only can be used to transfer data between applications, but also can become the information exchange standard between component programs.

4. Clipboard

The Clipboard is a system-wide shared data buffer, and each application can access the Clipboard through the API functions provided by the system. Its three standard operations are: Cut, copy, paste.

Before introducing a unified data transfer mechanism for COM, Windows systems provided a set of API functions and predefined cf_*** standard formats that include text types, bitmap types, metafile (metafile) data, and so on, and that data must be stored in global memory. However, after the Clipboard technology has been combined with the data object, the situation has changed greatly, which can be used to transfer data objects, such as OLE document objects, ActiveX control objects, or custom data objects in the application, as long as this object implements the IDataObject interface. The clipboard becomes the communication protocol between the provider and the receiver of the data object, and this mode of communication is done asynchronously.

5, drag-and-drop

Drag-and-drop technology is also a basic transport protocol, it is used in a different way than the Clipboard, the program in a synchronized manner.

6. Data structure FORMATETC and Stgmedium

The FORMATETC structure defines the data format for transmission, which expands the basic clipboard data format; The STGMEDIUM structure defines the type of media used for transmission, which can describe commonly used global memory or other storage media.

7. Data object and IDataObject interface

The data object in the unified data transmission is a COM object, which implements the IDataObject interface. Between the implementing party of the data object (i.e. the provider) and the customer (that is, the receiver), the IDataObject interface establishes the standard for both, and various transport protocols such as clipboard and drag-and-drop, which are actually passing the IDataObject interface pointers.

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.