Why a DLL has to be self-registered?

Posted on 2004-08-16
Last Modified: 2008-02-07
This is more of a curiosity question than anything.

Does every dll you create have to be made with the self-register option?  What's the difference with making a dll non-self registerable?  What's the downside to that?

Question by:dredg
  • 2
  • 2
  • 2
  • +1
LVL 19

Expert Comment

ID: 11815780
Only COM dll's need to be registered, though I suppose you could use this feature for other reaons in your dlls.

You can make them without the ability to self-register.

A dll that cannot self-register lacks the DllRegisterServer entry point.  This is the function that is called if you try to run regsvr32 on the dll.

The DllRegisterServer method should build all the necessary COM registry entries for the dll.

The downside of not doing it is that you will need to provide an alternate means of registration or no one will be able to use your COM dll easily (maybe not at all depending on what else you provide).

Expert Comment

ID: 11818952
A self register DLL exposes the well defined method DllRegisterServer - as drichards has detailed well.

A non-self registerable usually has an associated type library (could either be embedded within the DLL or stand-alone). Registration is then performed via the API RegisterTypeLib.

It's becoming more and more frequent whereby a self-registering DLL simply calls RegisterTypeLib on an embedded type library.

Who knows, registration could be performed by an installation package/program.

Author Comment

ID: 11821144
^^^So when you make a dll in Visual Studio, and you don't use the self-register that why a .lib file usually will come with the dll?  So if I make the dll self-registerable......there will be no .lib file with it?

Do I have this right?

BTW, thanks guys for the info.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

_ys_ earned 50 total points
ID: 11821658
Type library has the extension .tlb *not* .lib.

It's also always generated as long as your doing COM (have a .idl file).

Author Comment

ID: 11872896
sorry....forgot to do that.

Expert Comment

ID: 11980066

Some related info about VB6 DLL's

VB6 generates the DllRegisterServer entry point by default, when building a project that has a publicly instantiable object (in VB6, a "Class") but having it is one thing, you don't have to register an ActiveX dll to use it, the entry point is there should you care to use it.

There are techniques by which VB ActiveX dll's can be invoked via the API, and can self-instantiate, or be instantiated by a client, without  going through the registry.  A kind of private COM service,  although the primary objective from a VB6 systems programmer is to enable a VB dll to be used as a "normal" DLL (ie. via API), but still provide a VB GUI service!

One approach to this is to build the ActiveX dll and replace the normal entry point with a  DllMain function that can automatically do the required COM initialisation as part of the normal LoadLibrary() startup procedure.....

Theoretically an "EveryMan's" VB6 ActiveX DLL might be perfectly capable of being all things (COM and API)  to all callers (VB, and not VB) ...

Jim White
MathImagics Software Engineering
Surrey UK

Expert Comment

ID: 11980082

I forgot to add the observation, that knowing these things can be done in VB6 would suggest that a similarly exotic DLL could also be done in Visual C,  or any language, where it would actually be easier to implement, I would imagine.  We have some extra hoops we must jump through with VB6 ;)


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question