Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Why a DLL has to be self-registered?

Posted on 2004-08-16
Medium Priority
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.

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Accepted Solution

_ys_ earned 200 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

If you haven’t already, I encourage you to read the first article ( in my series to gain a basic foundation of R and R Studio.  You will also find the …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

670 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