Re: How to program plugin DLL's
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/07/05
- Next message: Ajay Kalra: "Re: Getting keystrokes in a control on a dialog"
- Previous message: AliR: "Re: Getting keystrokes in a control on a dialog"
- In reply to: Jaime Stuardo: "How to program plugin DLL's"
- Next in thread: Jaime Stuardo: "Re: How to program plugin DLL's"
- Reply: Jaime Stuardo: "Re: How to program plugin DLL's"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Ajay Kalra: "Re: Getting keystrokes in a control on a dialog"
- Previous message: AliR: "Re: Getting keystrokes in a control on a dialog"
- In reply to: Jaime Stuardo: "How to program plugin DLL's"
- Next in thread: Jaime Stuardo: "Re: How to program plugin DLL's"
- Reply: Jaime Stuardo: "Re: How to program plugin DLL's"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|