Re: How to program plugin DLL's

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/07/05


Date: Mon, 07 Feb 2005 14:35:22 -0500

Key here is to define the behavior of each of the interfaces. For example, that an
interface takes a CWnd * to which messages are posted to indicate device status is one
approach I've taken.

One thing I did was put in the comments of the VERSIONINFO object a comment like
Device:name here
and then when my app starts up, I use GetModuleFileName to locate the directory, do a
FindFirstFile/FindNextFile to look for *.dll, and for each DLL found, use the
GetVersionxxx APIs to get the comment. If the comment starts out as "Device:" then I took
the name and added it to a menu (my choice was to use a menu) of possible devices. Each
DLL would be responsible for enumerating its devices, so you'd call an interface function
to say "Tell me the names of each device you understand" and get back some sort of list
that I could add to the tree control.

There is no problem with loading multiple DLLs. As long as their names are different, such
as A.DLL and B.DLL, there is no challenge. What I would do is put a pointer to a struct in
the LPARAM of the tree item, and this pointer would reference a struct that had pointers
to the methods in it. You would get these from GetProcAddress after you loaded the DLL.
Thus, when you double-click an entry, you go out, get the LPARAM for that entry, and you
have the vectors to the DLL so you can query it, ask it for status, etc., etc.

You could also set your program up so that if you loaded a DLL and asked it to enumerate
its devices that if the enumeration list was empty, you could then choose to eliminate its
entire entry from the tree.
                                joe
On Mon, 7 Feb 2005 06:01:04 -0800, "Jaime Stuardo"
<JaimeStuardo@discussions.microsoft.com> wrote:

>Hi all...
>
>I'm programming an MDI application that controls some devices connected to
>serial port or Ethernet LAN.
>
>That application will support different type of devices and to make it
>modular, I will program each device type functionality in DLL's.
>
>I'm planning that when I add support to a new device, I need to program only
>a DLL and after copying it to the application directory, the application
>recognizes automatically the DLL and may add those kind of devices.
>
>As an example, support I have 2 kind of devices, A and B. Both controlled by
>A.DLL and B.DLL, respectively.
>
>In the tree will appear:
>
>- Devices
> - A type
> - DevA 1
> - DevA 2
> - B type
> - DevB 1
>
>By double clicking a node, a status window will appear. Of course, that
>status window depends on the kind of device. That window is popped up by a
>function named ShowStatus present in the plugin DLL. Now the tricky part: By
>double clicking DevA 1 node, ShowStatus of A DLL will be called. On the other
>hand, when DevB 1 node is double clicked, ShowStatus of B DLL will be called.
>
>Any advice about how can I achieve this?
>Thanks a lot in advance
>
>Jaime

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Properties Shared Amongst Objects
    ... The host can query my application for certain ... In that context one usually strives to provide a subsystem interface that reflects the invariants of the DLL subject matter. ... A some point the conversion may become so complex that one wants to deal with it explicitly within the DLL subject matter. ...
    (comp.object)
  • Re: Explicit Linking of DLLs in VB.net
    ... yes this technique will only work on managed assemblys (exe or dll) ... "YourObject" is a form and is limited to the form methods. ... Wel implement propertys, methods, events in your interface and start ... Public Shared Function LoadMeByName(ByVal vstrAssemblyName As String, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Explicit Linking of DLLs in VB.net (attn Michel or any others)
    ... loads the dll and finds a form in the dll. ... Dim extForm As Form = extAssembly.CreateInstance("test.entry", ... Wel implement propertys, methods, events in your interface and start ... Public Shared Function LoadMeByName(ByVal vstrAssemblyName As String, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem marshalling interface pointer into local server
    ... It can be applied to the proxy/stub DLL as well. ... Mind you this is not the most efficient way of producing a DLL ... Now that would be correct - an Automation-compatible interface ... I had an issue where I have a in-proc server (server ...
    (microsoft.public.vc.atl)
  • Re: Implements Interface difference in VB IDE and Compiled version, is this a BUG!???
    ... You need to set binary compatibility to the compiled dll. ... > it seams that VB in IDE Runtime mode with ActiveX component doesn't ... > |> TLB file contains interface IWPSpecific, ...
    (microsoft.public.vb.general.discussion)