Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


DLL,registering, source code, entry points and etc.

Posted on 2004-03-31
Medium Priority
Last Modified: 2011-09-20
I have a simple windows 32-bit DLL File all written and it is working quite well.  But when I try to register it at the dos prompt or thru a setup program, errors appear - meaning it can not register the DLL.  Within the DLLMAIN program, there are four areas:    (I am simplifiying here)
  1) primary attach
  2) primary detach
  3) secondary attach
  4) secondary detach.
 But my question, is how do I register my dll from within my dll file OR from/via a setup program OR from the dos prompt.  The errors I recieve, is that there are no entry points for registering and unregistering the DLL file.  This is the area I need the most help in.  And is there other areas/things that I need to accomplish this, that I do not have that I need to make this operation run smooth??  I have this project I am trying to deploy, and I have run into this problem. Can you help me out please.  Can you please provide (in straight "C") source code examples on how this is answered and solves my problem(s).  



Question by:midnightexpress
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

Expert Comment

ID: 10726710
I'm not sure what you're trying to do - is this a COM dll?

if not, you dont need to register it at all - as soon as you have the dll file it is ready to use, you just need to place it in your PATH so that windows can find it when needed.

please explain how you intend to use this DLL.
LVL 86

Expert Comment

ID: 10726759
Check out

http://support.microsoft.com/default.aspx?scid=kb;en-us;207132 ("INFO: How Regsvr32.exe Registers and Unregisters COM DLLs")

You need to export DllRegisterServer and DllUnregisterServer using the correct linkage (C, not C++) and export modifiers, e.g.

#ifdef __cplusplus
extern "C"      
STDAPI DllRegisterServer(void);

#ifdef __cplusplus
extern "C"      
STDAPI DllUnregisterServer(void);

Author Comment

ID: 10770520
Hello jkr:

 What I am looking for is an actual Windows DLL file that is registrable and unregistrable from either the dos prompt or via a setup program.  The one I have is a windows 32 bit dll file (with a DLLMAIN - having four sections), and it has neither the registration features that I am looking for.  In going thru my MSVC++ 6.0 environment, there is DLL file option that is called: "MFC APP Wizard DLL", is this the option that I should to take?  But the problem is that I do not understand MFC environment/concepts.  I do not know how to incorporate my "C" functions and ideas and existing DLLMAIN functions into this "MFC APP Wizard DLL" file(if this is the right option).  Can you build/(put together) this type of MFC DLL with the features that I am looking for with some working examples on how it is done?   The points still stand or do you need more points for an incentive to solve this problem.  I am in a project jam without this DLL file, with those desired features.



Accepted Solution

mturk1 earned 1500 total points
ID: 10821208
Seems that you have a plain DLL file.
Having such a file you don't need to, or to be more specific, you cannot register that file using COM mechanism that is present in regsvr32.exe utility.

The COM dll has register and unregister methods that are meant to be used by the system to uniquely define the DLL file itself.

So unless you don't need to have a COM functionality (for example having your code accessible from scripting languages), you don't need those registration functions at all. All that you have to do is to copy the dll an all it's dependencies to the target computer, and you are ready to use them. On contrary for COM dlls you need to register them after copying to the target computer, so that target machines COM marshaler is aware of your dll.

Other question is whether you wish to produce the COM dll. If you wish to do that then using MSVC6 you will have to use the 'ATL COM AppWizard' and select DLL as a Server Type.
The wizard will generate the needed stub for registering and unregistering this dll. It will generate the new DllMain too and four other exported functions:


You may try to add your existing code, recompile and add all your export methods to the .def file if not using __stcdall. In theory you will still be able to use the dll as normal one and have a option to register/unregister it.

The usability of such a procedure is questionable, and I cannot see any practical
reason for wrapping exiting dll to a COM one, but if it make you happy, well :-)


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.

604 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