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