Previously, we always thought that a DLL (or EXE) is a COM component. Different classes in the DLL are different interfaces, and CLSID is used to identify a DLL or EXE.
In fact, this is wrong !!!
A component is not necessarily a DLL. a dll can contain many components. Generally, a dll contains more than one component. Each component in a DLL has its own
CLSID and progid. For an ATL Project, an ATL object is a component. Obviously, we can add many ATL objects to a project.
For ATL, a component corresponds to a C ++ class, which is called coclass in IDL. Generally, a coclas corresponds to an interface. In fact, a coclass can have many interfaces. This means that a component implements multiple interfaces and these interfaces share functions in a component.
For example, coclass A has an interface IA, and the interface exports a function Foo (), so coclass
A has a FOO () function to implement the Foo () function in the IA interface. Later, I want to upgrade component A and add an export function foo2 (), but I don't want to affect the previous users. Of course I want to redo it.
A new component is fine, but it is unnecessary and has repeated code. In this case, we can create a new interface ia2 in component A and ia2 to export two functions: Foo () and
Foo2 (), ia2 is still implemented by coclass A, that is, the current coclass
A has two functions: Foo () and foo2 (). The interfaces Ia and ia2 share coclass.
The Foo () function in. In this way, the previous users do not need to change, because the interface IA is not changed, new users can use the interface ia2, and ia2 can still complete the IA function, because
There are also Foo () functions.