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

x
?
Solved

Finding a class in a dll

Posted on 1998-10-22
5
Medium Priority
?
233 Views
Last Modified: 2013-11-20
I'm doing a flowchart type program. Each shape is drawn in a class derived from a base class called CShape. I would like to put this derived classes in DLL's and load them at run time, getting the names of the dll's that contain shapes in the registry.

Here is my question: How do open the dll's (LoadLibary I know) retrive the Shape classes for use? Remember I do not know anything about the classes at compile/link time, only registry entries for the DLL file names.

Thanks
Thomas

PS: is COM a solution?
0
Comment
Question by:SirThomas
[X]
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
5 Comments
 
LVL 2

Expert Comment

by:Belgarat
ID: 1323725
You can enumerate a functions exported from the DLL, but you'll have to strip decoration added by the C++ compiler to the names.
The second approach is to create a special function like EnumSupportedClasses() in the DLL, that returns array of class names.
However, you CAN'T specify class name as a variable in some variable declaration, so this information will be useless to you anyway. If your DLL classes are descendants of some CShape, you can export function CreateShape(char *pShapeName) that returns a pointer to a new allocated instance of the requested shape class. If you use virtual functions in the CShape class, you'll be able to call the descendant's implementations through them.

0
 
LVL 2

Expert Comment

by:cyrilbdt
ID: 1323726
create dll project and put all classes you want. use __declspec for classes
you want to be available from this dll.
when the ptoject is compiled in debug/release directory ther is a some.lib file.
Add this file to your project and make sure that there is path to some.dll

file.h
*************
class __declspec(dllexport) CMyClass{
public:
      .....
};
************


0
 

Author Comment

by:SirThomas
ID: 1323727
I need to get this information at run time not compile/link time. If this user creates DLL for my app, in his office in china, I do not want to recompile my program to add his dll to my project, in the US. I need this more dynamic.
0
 

Accepted Solution

by:
Maizlish earned 200 total points
ID: 1323728
Yes COM is a solution.
I can suggest something that resembles COM if you do not want to mess with it only for
classes information.
You can decide that each dll that will participate in your application ( every dll that will be retreived from the registry ) MUST have class ( lets call it CEnumerator ) and this class
has function ( lets call it GetClass(es) ) . This way you can get classes hidden in the DLL
If you word some more on this CEnumerator you can make it give some more usefull information

this is very much like COM's ideas of interfaces , but there is no need to add COM to your application just for this reason

Hope it helps ,
Oleg
0
 
LVL 2

Expert Comment

by:cyrilbdt
ID: 1323729
Sorry, I don't read to question correctly. Shure this will not help.
0

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

722 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