1. For in-process components, you can take advantage of the Regsrv32.exe provided by the Windows system.
For example, run: RegSrv32 d:\com.dll (REGSRV32 runtime calls Com.dll's derivation function Dllr
Egisterserver, True registration is implemented in DllRegisterServer)
If you want to reverse register, you can use: regsrv32/u d:\com.dll (call dllunregsrvserver function at this time)
2. For out-of-process components, because it is an executable file, it is not necessary to provide an extraction function for other program calls to implement registration.
The COM specification stipulates that out-of-process components that support self registration must support two command parameters/regserver and/unregserver to implement registration and reverse registration operations.
3. Implement automatic Uninstall
The condition of the Component object being unloaded: 1, the number of objects in the component is 0 2, and the class factory lock counter is 0.
COM provides a function cofreealllibraries, which detects all component programs in the current process and calls the FreeLibrary Uninstall component when it finds a satisfying condition.