Solved

Why a DLL has to be self-registered?

Posted on 2004-08-16
8
892 Views
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?

Thanks.
0
Comment
Question by:dredg
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 19

Expert Comment

by:drichards
Comment Utility
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).
0
 
LVL 9

Expert Comment

by:_ys_
Comment Utility
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.
0
 

Author Comment

by:dredg
Comment Utility
^^^So when you make a dll in Visual Studio, and you don't use the self-register option.......is 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.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 9

Accepted Solution

by:
_ys_ earned 50 total points
Comment Utility
Type library has the extension .tlb *not* .lib.

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

Author Comment

by:dredg
Comment Utility
sorry....forgot to do that.
0
 

Expert Comment

by:mathimagics
Comment Utility

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
0
 

Expert Comment

by:mathimagics
Comment Utility

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 ;)

Cheers
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now