Click to See Complete Forum and Search --> : Dynamically load/use dialog COM objects from multiple .ocx/.dll files? Help!


Dorothy Nelson
April 5th, 1999, 08:55 PM
Hi all,

I have combed and combed MSDN, codeguru, etc. and I've gotten nowhere. But it seems like what I want to do is pretty reasonable...

I have an application where a set of wizards/dialogs will complete an import database task. Since there are many database types, I wish to allow programmers to develop COM objects which will provide dialogs and import functionality according to an API that I have mostly designed already. My initial idea is that the programmer would drop their .ocx containing their API-conformant COM object in a special directory, and at import time I will read all the .ocx files and display an icon for each, then when the icon for a particular .ocx is chosen I will launch the Dialog API method that the .ocx provides.

What I don't know is:
0. Am I missing a smarter way to do this? If not...
1. How do I read/dynamically load the .ocx's from the Application?
2. Can I use smart pointers with the dynamically loaded COM objects?
3. Any other info you'd like to add?

Eternal gratitude and some See's candies for some help here... (help!) I will provide a scaled-down example for the codeguru database once this has been worked out (if it's of interest to codeguru, of course).

thanks in advance...
--Dorothy

Dave Lorde
April 6th, 1999, 09:15 AM
The key to this is deciding how your application will pick up the fact that these OCXs/DLLs are available.

When a COM OCX/DLL is installed on a system, it must be registered, inserting an entry into the registry so that COM can find it when the interface is requested.

So how can your application discover that a relevant interface has been registered?

One way to do it would be to have each OCX/DLL also register itself with the application at install time. In other words, as well as the standard registration process, each OCX/DLL adds it's CLSID to a known registry key 'owned' by the application (possibly adding a brief description, tooltip text, and path to its icon).

The application can now read the list of relevant registered objects from its registry list, pick up any details such as titles, tooltips, and icons, and display the icon in a toolbar or similar. It can use the CLSID listed to create an instance of the relevant COM object when selected.

Just a thought...

Dave

Dave Lorde
April 6th, 1999, 09:18 AM
Oh, and yes, always use smart pointers and the interface wrapper macros, and all that stuff, it makes life much simpler and safer.

Dave