Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Plugin System in Visual C++

Plugin System in Visual C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdata-structuresquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    albuemil
    wrote on last edited by
    #1

    Hy. I'm trying to create a program that needs plugins. My problem is that i found quite a few methods of creating plugins, and i don't know wich method to use (wich one is better). Anyway, here's what i need to be able to do: - plugins must be able to access a list of data from the main program (for modifying it) - plugins can show their own dialogs when executed - i'd like to implement a Plugin Config system like Winamp3 has (there's a tree with each plugin as a treenode, and when you select one of them, the right side shows the plugin's config dialog) - plugins should be able to add new commands to the main menu and toolbar of the application that loads them. - also, the user should be able to select wich plugins not to load So, if anybody has a good ideea on how can i make this all, please help me.

    L R T 3 Replies Last reply
    0
    • A albuemil

      Hy. I'm trying to create a program that needs plugins. My problem is that i found quite a few methods of creating plugins, and i don't know wich method to use (wich one is better). Anyway, here's what i need to be able to do: - plugins must be able to access a list of data from the main program (for modifying it) - plugins can show their own dialogs when executed - i'd like to implement a Plugin Config system like Winamp3 has (there's a tree with each plugin as a treenode, and when you select one of them, the right side shows the plugin's config dialog) - plugins should be able to add new commands to the main menu and toolbar of the application that loads them. - also, the user should be able to select wich plugins not to load So, if anybody has a good ideea on how can i make this all, please help me.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I have written a plugin system for a game launcher, and it works very fine and very similar to the one in Winamp2. The exe loads all .dll files in the plugin directory using LoadLibrary(). Of yourse you can make it selectable which files should be loaded. In order to access data from the main program I have an exported function in my DLL that accepts a pointer parameter, here's an example:

      extern "C" __declspec(dllexport) void _stdcall OnJoinServer(const hlla_SERVER* server)

      Before you can user any exported functions I find their address in the DLL using GetProcAddress() To bring up a configuration dialog I export e function in my DLL called OnConfigure; the exe calls this function if the user clicks on "Configure" in the main app. Inside the OnConfigure function in the DLL I simply open the configuration dialog using DoModal(). When my app finishes I close all handles to the plugins (dlls) with FreeLibrary() regards Greg

      A 1 Reply Last reply
      0
      • A albuemil

        Hy. I'm trying to create a program that needs plugins. My problem is that i found quite a few methods of creating plugins, and i don't know wich method to use (wich one is better). Anyway, here's what i need to be able to do: - plugins must be able to access a list of data from the main program (for modifying it) - plugins can show their own dialogs when executed - i'd like to implement a Plugin Config system like Winamp3 has (there's a tree with each plugin as a treenode, and when you select one of them, the right side shows the plugin's config dialog) - plugins should be able to add new commands to the main menu and toolbar of the application that loads them. - also, the user should be able to select wich plugins not to load So, if anybody has a good ideea on how can i make this all, please help me.

        R Offline
        R Offline
        Ryan B
        wrote on last edited by
        #3

        Im in the process of developing an application that requires a imilar plugin architecture. However, unlike the last response, I have chosen COM as a way of handling such things. I have not solved, or identified all of the problems associated with doing it this way, but heres the basis for my design. - Component Categories in COM would allow my applicaiton to load any registered component on the system thats fits into my architecture. - Using a simple, but efficiently designed interface that will allow my app to identify, and understand each component. This interface would be common across every "plugin". - an IConfig interface could handle executing the plugins configuration, but the implementation would be specific to each plugin. - The main applicaiton contains the list of useable and loaded plugins. It could then easily generate a tree view that lists each plugin as a node along with access to the IConfig interface. - Almost every plugin will be presented as an child window in an MDI application. - My applicaiton would require multiple intances of each plugin. - I have not solved the problem of presented a common data source to each of the plugins, but im also new to COM and have a shipment of books from Amazon heading my way. Ryan Baillargeon

        1 Reply Last reply
        0
        • L Lost User

          I have written a plugin system for a game launcher, and it works very fine and very similar to the one in Winamp2. The exe loads all .dll files in the plugin directory using LoadLibrary(). Of yourse you can make it selectable which files should be loaded. In order to access data from the main program I have an exported function in my DLL that accepts a pointer parameter, here's an example:

          extern "C" __declspec(dllexport) void _stdcall OnJoinServer(const hlla_SERVER* server)

          Before you can user any exported functions I find their address in the DLL using GetProcAddress() To bring up a configuration dialog I export e function in my DLL called OnConfigure; the exe calls this function if the user clicks on "Configure" in the main app. Inside the OnConfigure function in the DLL I simply open the configuration dialog using DoModal(). When my app finishes I close all handles to the plugins (dlls) with FreeLibrary() regards Greg

          A Offline
          A Offline
          albuemil
          wrote on last edited by
          #4

          Well, i've found a system that does the loading/unloading for me (look at http://www.codeproject.com/dll/plug-in.asp). My problem is that if i create MFC Extension DLLs, the LoadLibray and FreeLibrary functions don't work. So, i didn't find any way yet to use MFC classes in my DLLs. I need some help with this part, as this i think is the most important one (as my DLLs will use MFC classes) For the shared memory part (the list of data that plugins have to work with) i think i can send a pointer to that data (each plugin has a function that asks for that pointer), if anybody has a better ideea, please tell me. For the Winamp like configuration i suppose that's not that extremly important, so i could leave it for a latter time (or leave it out completely from the project), so for now each plugin shows its own dialog with configurations.

          L 1 Reply Last reply
          0
          • A albuemil

            Well, i've found a system that does the loading/unloading for me (look at http://www.codeproject.com/dll/plug-in.asp). My problem is that if i create MFC Extension DLLs, the LoadLibray and FreeLibrary functions don't work. So, i didn't find any way yet to use MFC classes in my DLLs. I need some help with this part, as this i think is the most important one (as my DLLs will use MFC classes) For the shared memory part (the list of data that plugins have to work with) i think i can send a pointer to that data (each plugin has a function that asks for that pointer), if anybody has a better ideea, please tell me. For the Winamp like configuration i suppose that's not that extremly important, so i could leave it for a latter time (or leave it out completely from the project), so for now each plugin shows its own dialog with configurations.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            LoadLibrary and FreeLibrary work like a charm for me in MFC Extension DLLs :confused:

            A 1 Reply Last reply
            0
            • L Lost User

              LoadLibrary and FreeLibrary work like a charm for me in MFC Extension DLLs :confused:

              A Offline
              A Offline
              albuemil
              wrote on last edited by
              #6

              Then i'll have to look over it again, maybe i made some mistake. Anyhow, i'll get back with more info (i'll have to make some tests). Thanx anyway. ----------------------------------- Ok, i looked it over, it didn't load the dlls as i made a mistake when i declared them, now i can load MFC extension DLLs too. Thanx.

              1 Reply Last reply
              0
              • A albuemil

                Hy. I'm trying to create a program that needs plugins. My problem is that i found quite a few methods of creating plugins, and i don't know wich method to use (wich one is better). Anyway, here's what i need to be able to do: - plugins must be able to access a list of data from the main program (for modifying it) - plugins can show their own dialogs when executed - i'd like to implement a Plugin Config system like Winamp3 has (there's a tree with each plugin as a treenode, and when you select one of them, the right side shows the plugin's config dialog) - plugins should be able to add new commands to the main menu and toolbar of the application that loads them. - also, the user should be able to select wich plugins not to load So, if anybody has a good ideea on how can i make this all, please help me.

                T Offline
                T Offline
                Todd Smith
                wrote on last edited by
                #7

                Just remember if you allocate memory from your DLL you have to free it from your DLL. One way to get around this is to pass a function pointer to your DLL for allocating memory. Todd Smith

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups