Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does registering a DLL do?

Tags:

windows

dll

com

I know how to register dlls but I've never really been sure why I'm doing it or under what conditions a dll must be registered. Could somebody explain or point me to some documentation?

like image 734
stimms Avatar asked Mar 06 '09 23:03

stimms


People also ask

Do I have to register a DLL?

Regsvr32 is used to register and unregister Object Linking and Embedding (OLE) controls, like DLL files and ActiveX Control . OCX files. You may need to register a DLL file if you see a DLL error on your computer.

Why is it important to register a DLL file in Windows?

Microsoft Office, for instance, registers dlls that exposes COM interfaces that allows other applications to incorporate functionality from the Office applications.

What is DLL register Server?

When a DLL is registered, the DllRegisterServer method entry point in your DLL is invoked. Similarly, DllUnregisterServer is invoked when a DLL is unregistered. As described in this MSDN article: Instructs an in-process server to create its registry entries for all classes supported in this server module.

Do you need to reboot after registering a DLL?

No, you need no reboot when registering a new COM server.


2 Answers

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

As described in this MSDN article:

Instructs an in-process server to create its registry entries for all classes supported in this server module. If this function fails, the state of the registry for all its classes is indeterminate.

For COM DLLs, you will need to implement your own DllRegisterServer and DllUnregisterServer entry point methods which do the registering/unregistering as appropriate. Example code for DllRegisterServer can be found here.

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

DllUnregisterServer will do the reverse, and remove all of the CLSIDs from the registry that were put in there by DllRegisterServer.

More general information about DllRegisterServer can be found here.

like image 68
LeopardSkinPillBoxHat Avatar answered Oct 07 '22 22:10

LeopardSkinPillBoxHat


What is most commonly referred to as DLL registering is when it implements a COM object. regsvr32 ensures that an instance of the object can be created. When e.g. VBScript uses New or CreateObject(), the registration ensures that COM knows what DLL to load in order to make a new instance, whether by name or CLSID.

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

like image 25
Pontus Gagge Avatar answered Oct 07 '22 22:10

Pontus Gagge