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. how to design the architecture?

how to design the architecture?

Scheduled Pinned Locked Moved C / C++ / MFC
c++designalgorithmsarchitecturehelp
7 Posts 2 Posters 1 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.
  • F Offline
    F Offline
    Falconapollo
    wrote on last edited by
    #1

    At first, let me describe our current architecture: Our project is based on MFC multiple doc view, and the project contains many submodules. The submodule contains two projects: one is a resource-only prject(dll), and another is a static library project. We extract resources from the dll(generated by resource-only project), then generate a *.cpp file which contains alll the resource data, include the *.cpp into static project. After linking with the static library, the Main Frame must use some helper functions to extract resources from *.cpp when it must use the resource from submodule. Now I want to find a better architecture to replace the current one, because its complexity of managing resource is sooo high. Anybody can help me? I'm not sure these words can make you understand me correctly?

    _ 1 Reply Last reply
    0
    • F Falconapollo

      At first, let me describe our current architecture: Our project is based on MFC multiple doc view, and the project contains many submodules. The submodule contains two projects: one is a resource-only prject(dll), and another is a static library project. We extract resources from the dll(generated by resource-only project), then generate a *.cpp file which contains alll the resource data, include the *.cpp into static project. After linking with the static library, the Main Frame must use some helper functions to extract resources from *.cpp when it must use the resource from submodule. Now I want to find a better architecture to replace the current one, because its complexity of managing resource is sooo high. Anybody can help me? I'm not sure these words can make you understand me correctly?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      As I understand it, you're extracting the resources from a DLL, embedding it into a static library and then again extracting it from the static library. What I don't understand here is, why the double extraction. Why not extract the resources directly from the DLL by the frame? Is it because it should be a single EXE without any DLLs? If you're able to use the EXE along with the DLLs, then the design can be in such a way that the EXE, at runtime, extracts the resources from the resource only DLL and calls into the static library passing it the extracted resource. If multiple files are the problem, it is even possible to embed the resource only DLL into the EXE itself. If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself.

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++) (October 2009 - September 2013)

      Polymorphism in C

      F 1 Reply Last reply
      0
      • _ _Superman_

        As I understand it, you're extracting the resources from a DLL, embedding it into a static library and then again extracting it from the static library. What I don't understand here is, why the double extraction. Why not extract the resources directly from the DLL by the frame? Is it because it should be a single EXE without any DLLs? If you're able to use the EXE along with the DLLs, then the design can be in such a way that the EXE, at runtime, extracts the resources from the resource only DLL and calls into the static library passing it the extracted resource. If multiple files are the problem, it is even possible to embed the resource only DLL into the EXE itself. If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself.

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++) (October 2009 - September 2013)

        Polymorphism in C

        F Offline
        F Offline
        Falconapollo
        wrote on last edited by
        #3

        At first, thank your for your reply. yes, you are right. because it should be a single EXE without any DLLs. >>it is even possible to embed the resource only DLL into the EXE itself. could you explain how to do it? If successfully do it, how can submodule access the resource? >>If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself. as far as i can see, it's not possible to embed resources into static library directly, could you explain your idea?

        _ 1 Reply Last reply
        0
        • F Falconapollo

          At first, thank your for your reply. yes, you are right. because it should be a single EXE without any DLLs. >>it is even possible to embed the resource only DLL into the EXE itself. could you explain how to do it? If successfully do it, how can submodule access the resource? >>If you do not want the resource extraction to be done at runtime, you could embed the resources in the static library itself. as far as i can see, it's not possible to embed resources into static library directly, could you explain your idea?

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Falconapollo wrote:

          >>it is even possible to embed the resource only DLL into the EXE itself.
          could you explain how to do it? If successfully do it, how can submodule access the resource?

          To embed a DLL in the resource, first create a custom type resource - Right click on the .rc file in the resource view and select Add Resource -> Custom. Give it any name like DLL. The newly created resource will open in a binary editor and will be blank. Now open the DLL file using the binary editor by using File -> Open, select the DLL and choose Open With -> Binary editor. Select all the contents of the DLL (Ctrl + A), copy and paste it in the newly created resource file and save it. To access the resource at runtime, do the following - Use FindResource[^] to locate the resource. Use SizeofResource[^] to get the size of the resource. Use LoadResource[^] to get a handle to the resource. Use LockResource[^] to get a pointer to the memory where the resource is loaded. Use CopyMemory[^] to copy the resource contents into a buffer. Now Create a new binary file using CreateFile[^]. Use WriteFile[

          F 1 Reply Last reply
          0
          • _ _Superman_

            Falconapollo wrote:

            >>it is even possible to embed the resource only DLL into the EXE itself.
            could you explain how to do it? If successfully do it, how can submodule access the resource?

            To embed a DLL in the resource, first create a custom type resource - Right click on the .rc file in the resource view and select Add Resource -> Custom. Give it any name like DLL. The newly created resource will open in a binary editor and will be blank. Now open the DLL file using the binary editor by using File -> Open, select the DLL and choose Open With -> Binary editor. Select all the contents of the DLL (Ctrl + A), copy and paste it in the newly created resource file and save it. To access the resource at runtime, do the following - Use FindResource[^] to locate the resource. Use SizeofResource[^] to get the size of the resource. Use LoadResource[^] to get a handle to the resource. Use LockResource[^] to get a pointer to the memory where the resource is loaded. Use CopyMemory[^] to copy the resource contents into a buffer. Now Create a new binary file using CreateFile[^]. Use WriteFile[

            F Offline
            F Offline
            Falconapollo
            wrote on last edited by
            #5

            Thank you for your quick reply. One more question: what if i modify our resources more frequently? it seems unconvenient to embed resources into static lib or exe, because i can't edit them directly...

            _ 1 Reply Last reply
            0
            • F Falconapollo

              Thank you for your quick reply. One more question: what if i modify our resources more frequently? it seems unconvenient to embed resources into static lib or exe, because i can't edit them directly...

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              Actually, you can - Using Resources[^] :)

              «_Superman_»  _I love work. It gives me something to do between weekends.

              _Microsoft MVP (Visual C++) (October 2009 - September 2013)

              Polymorphism in C

              F 1 Reply Last reply
              0
              • _ _Superman_

                Actually, you can - Using Resources[^] :)

                «_Superman_»  _I love work. It gives me something to do between weekends.

                _Microsoft MVP (Visual C++) (October 2009 - September 2013)

                Polymorphism in C

                F Offline
                F Offline
                Falconapollo
                wrote on last edited by
                #7

                um...you might misunderstood me,i meants it's inconvenicent to edit *.rc file directly, for instance, adding dialog, adding strings, adding icons... it's even more inconvenient to use function: UpdateResource...

                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