• C

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

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

Thanks(TIA!)!

 Midnightexpress
 

midnightexpressAsked:
Who is Participating?
 
mturk1Connect With a Mentor Commented:
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:

DllCanUnloadNow
DllGetClassObject
DllRegisterServer
DllUnregisterServer


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

MT.
0
 
shalmakCommented:
Hi
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.
0
 
jkrCommented:
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"      
#endif
STDAPI DllRegisterServer(void);

#ifdef __cplusplus
extern "C"      
#endif
STDAPI DllUnregisterServer(void);
0
 
midnightexpressAuthor Commented:
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.

 THanks(TIA),

 Midnightexpress
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.