C ++, DLL, COM, COM + overview

xiaoxiao2021-03-06  21

The common way of using C write code under Windows is probably C , DLL, and COM 1, C code reuse defects, C developer multiplexed code, is probably a set. H and .cpp file Then, then add these files to its own engineering, connect, and finally generate the EXE file. This type of code level is equipped with the following issues 1, C programmers usually modify the code provided by others according to their own needs. Developers want to use code, usually understand the intent of the code based on source code. More old, it is necessary to understand the ideas and coding styles of code providers. 2, C code level reuse results in waste of hard disk and memory space, if there is N software on the machine, in each software There will be a compile-generated code of Class CA in the storage space. When this N software is executed, the N × SizeOf (CA) size memory space 3 is occupied, and the software is released, unless recompiled the entire software. Modifying if the class CA has a bug, to modify the CA implementation to fix this bug, then only recompile the entire software. Software does not have 2-based modular features. Second, how to solve the above problems - the introduction of the DLL in Window, a good technology is the dynamic link library (DLL), with DLL technology, customers can share the DLL code, so in the user machine How many software uses this DLL, there is only one copy of the DLL. And the DLL is also only .h file, hidden the implementation details of the code. Third, DLL multiplexing problems 1, compiler, connector incompatibility issues In order to support overload, C compiler modifies function names (name adaptation, interested, "can be referred to" in-depth exploration of C object model Chapter 4 - -Function Language "), and the method of modifying the function name each C compiler is usually different. One solution to this problem is to declare the extern "C" link indicator, and one of the defects do not use the Extern "C" to declare member functions. Another solution is to modify the DEF file, so that all compilers export the same function name to ensure that the DLL is compatible when the link is linked. However, this does not guarantee the compatibility of the 2-encyclopedia. Since the C standard does not specify the state of the program, each compiler may have its own way of handling, for example, when doing an abnormal process, a compiler throws out Exceptions, in another compiler, may not be able to have a 2, DLL fatal weaknesses - version conflict problem DLL version issues are notorious. The classic method for solving the version conflict is to rename the DLL file name (this is also the MFC solution, MFC42D ... .mfc42ud, etc.). Fourth, sacrifices the magic weapon, object-oriented principle-interface and implementation of the separation DLL version problem is the key to the C compilation model and the tight coupling relationship between the object, the C compilation model requires customers to understand the object's memory layout for Object allocates memory. The fundamental solution of this issue is to separate interfaces and implementation. The implementation is encapsulated inside the DLL, and the customer will access the implementation through the interface. In this way, the implementation portion of the multiplexed module is not included in the customer code. 5. The solution of COM is strictly separated interface and implementation, and customers can only access components through interfaces. It is guaranteed that no detail of any implementation is exposed to the customer. When the customer uses components to allocate memory, only the VPTR pointer in the COM interface. COM uses interface inheritance to separate the interface and implementation. Most compilers are consistent with the memory layout generated by VPTR and VTBL.

This solves the incompatibility relationship between the compiler. COM is proposed under Win2k, configuring COM components in component services, which comes into COM , is also the foundation of Windows DNA

COM = COM MTS MSMQ

转载请注明原文地址:https://www.9cbs.com/read-41990.html

New Post(0)