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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumDigits challenge 9 178
lucky13 challenge 11 167
Python 2.7 - French characters 6 186
numbers ascending pyramid 101 265
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This video teaches viewers about errors in exception handling.
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.

738 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