how to design the architecture?
-
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?
-
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?
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)
-
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)
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?
-
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?
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 usingFile -> Open
, select the DLL and chooseOpen 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[ -
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 usingFile -> Open
, select the DLL and chooseOpen 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[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...
-
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...
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)
-
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)
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...