What does DLL registration do?

I know how to register a DLL, but I was never sure why I do this or under what conditions a dll should be registered. Can someone explain or point me to the documentation?

+50
windows dll com
Mar 06 '09 at 23:22
source share
3 answers

When the DLL is registered, the entry point of the DllRegisterServer method in your DLL is called. Similarly, the DllUnregisterServer is called when the DLL is unregistered.

As described in this MSDN article :

Instructs the embedded server to create registry entries for all classes supported by the module on this server. If this function does not work, the status of the registry for all its classes is undefined.

For COM libraries, you will need to implement your own DllRegisterServer and DllUnregisterServer entry point methods, which, if necessary, register / unregister. Sample code for the DllRegisterServer can be found here .

The end result of registering a DLL is that all CLSIDs for components in the DLL are registered in HKEY_CLASSES_ROOT\CLSID . This allows CoCreateInstance find the correct server when creating COM objects from another DLL or application.

DllUnregisterServer will do the opposite and remove all CLSIDs from the registry that DllRegisterServer placed there.

More general information about DllRegisterServer can be found here .

+39
Mar 06 '09 at 23:27
source share

What is most often referred to as DLL registration is when it implements a COM object. regsvr32 ensures that an instance of the object can be created. When, for example, VBScript uses New or CreateObject (), registration ensures that COM knows which DLL to load in order to create a new instance, whether by name or CLSID.

See "layman's explanation" for a (very) brief summary.

+6
Mar 06 '09 at 23:28
source share

Just look at the source code of regsvr32.exe

+2
Mar 07 '09 at 10:06
source share



All Articles