The realization of COM principle and application----com

Source: Internet
Author: User

1, the implementation of COM and operating system platform is closely related

Because COM originated in the Microsoft Windows platform, the COM implementation part (that is, the COM library) uses some of the features of the Windows system directly, such as the system registry, the dynamic Connection library, and so on, but in fact COM is a platform-independent component software model. The COM standard used on Windows is just a concrete implementation of COM.

2, the realization of the method of COM

In-process components (DLLs, in-process component).

Out-of-process component (EXE, out–of-process component).

3, the DLL program creation method

(1) Create a DLL project

(2) When creating a DLL, you should use the _stdcall to invoke the custom derivation function and use the extern "C" specifier. This will ensure compatibility with other compilers and programming languages.

(3) According to the traditional programming method, a DEF file is written to describe the module information of the DLL program, which lists all the derivation functions and assigns a unique ordinal number to each derivation function. On the Win32 platform, you can use a DEF file without using the _declspec (dllexport) specifier directly in the function description, as follows:

extern "C" _declspec (dllexport) int _stdcall myfunction ();

4, client program to operate the DLL program three system functions

LoadLibrary, loading DLL module function

Getprocaddess, take the function of the address of the function

FreeLibrary, releasing functions for DLL programs

5, DLL's three point description

(1) For in-process components, because the client program is in the same address space as the DLL program, DLL programs can not only draw functions, but also draw global variables.

(2) VC + + provides the use of tool dumpbin, through the/EXPORTS option can be listed in the DLL program all the information presented. (LINK.EXE and MSPDB60.DLL support is required in actual operation)

(3) If the client program itself is also a DLL program, it must first be loaded into the process space.

6, out-of-process components and customer communication across the process boundaries work together

(1) Two questions

How a process calls a function in another process.

How parameters are passed from one process to another.

(2) Methods of communication between different processes on the Windows platform

Dynamic Data Exchange (DDE)

Named pipes (named pipe)

Shared memory

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.