Solved

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

Posted on 2004-03-31
4
440 Views
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).  

Thanks(TIA!)!

 Midnightexpress
 

0
Comment
Question by:midnightexpress
4 Comments
 
LVL 1

Expert Comment

by:shalmak
ID: 10726710
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
 
LVL 86

Expert Comment

by:jkr
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"      
#endif
STDAPI DllRegisterServer(void);

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

Author Comment

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

 THanks(TIA),

 Midnightexpress
 
0
 
LVL 1

Accepted Solution

by:
mturk1 earned 500 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:

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 opening and reading files in the C programming language.

707 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

20 Experts available now in Live!

Get 1:1 Help Now