Archived

This topic is now archived and is closed to further replies.

How to support plugins / inter-program-communication

This topic is 5676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently working on a project with a few guys. We wanna do something like this: We're gonna define some standards for data exchange and write a couple of programs to use this data. Now if you open a file with Program A and this file contains some pieces of data which aren't supported by Program A natively, the idea is to search for a program which can handle the data, call it, hand it the data, let it edit the data and take the edited data back. My idea was to have a central registry where each programs enters itself upon installation. So, when your program needs help, it can look into this registry, find the programs supporting this type of data and call them. But how exactly do you call parts of these foreign programs (we don't wanna call the whole program. Only the editing part) and get the data from them after they're done? We thought about using COM but I don't like this idea since you have to recompile each time you wanna support an additional program, which would be a great hassle in our case. The idea kinda works like plugins. The host program hands data to the client program, which in turn edits the data and returns it to the host program. I'm shure this has been done before. Oh, one more thing: the whole mess should be language independant and platform independant. Visual Basic specific tutorials or hints would be more than welcome. Thanks a lot in advance! ----------------------------- "Mr Sandman bring me a dream" [edited by - MrSandman666 on June 3, 2002 11:48:58 AM]

Share this post


Link to post
Share on other sites
It can be done with COM and the Implements keyword. First, read up on Implements and figure out what it does. It is sort of like Interface Inheritance, but more limited. Basically you would have a virtual base class with a name like IPlugin. IPlugin will not have any code, just sub and function definitions. You may want subs like Initialize, Shutdown, ShowOptions, etc. This would go in a core ActiveX DLL used by all programs. Other helper functions could also be included in this DLL.

Plugins would go in other ActiveX DLLs and would have classes that Implement IPlugin. If the IPlugin class had a method called ShowOptions, then the new class would have to include a method called IPlugin_ShowOptions. This works similar to how Forms implement events, but you have to write code for every implemented method. You can make as many DLLs as you want of this type.

Finally, you need the EXE project. It will only reference the core library, not any of the plug-in libraries. The plugin DLLs will have to be registered using RegSvr32 (done automatically on compile), and you will have to devise some way to choose which plugins to use. The way I do it is put plugins in a certain folder. Then you have to find out what DLLs in this folder are registered, and what their Project and Class names are. Then you do something similar to the following.

Dim PluginName as String
Dim Plugin As IPlugin
PluginName = "ProjectName.ClassName" ''something like this
Set Plugin = CreateObject(PluginName)

This will create an object of type ClassName, but it will be accessed through the IPlugin interface. You can''t access any additional methods that exist in your derived plugin class that don''t exist in IPlugin, but that shouldn''t matter.

I haven''t done this in a long time, so my memory is sketchy. But it works. You might search for something along the lines of "VB Plugins using Implements".

--TheMuuj

Share this post


Link to post
Share on other sites
Hmm... makes sense to me...
This should also work with complete programs, when you compile them as ActiveX EXEs... you could find the programs/plugins using this central registry file...

The only problem is that those programs are not designed to be plugins... I guess we need to come up with standards for this...

Anyways, this gave me a great start to do some more research and learning on this.

If there are any more ideas out there, let them come!

-----------------------------
"Mr Sandman bring me a dream"

Share this post


Link to post
Share on other sites