Is there a way for Visual Studio C++ development to embed binary files into a static library and use them from the executable?

Asked 2 years ago, Updated 2 years ago, 61 views

I'm looking for a way to embed the binary file into a static library and link it to the executable.

How do I embed binary files into a program and browse them in Visual Studio C++ development?


Add Binary, FindResourceW(...), and LoadResource(...) as described in
·If it is done on the executable side, it will work without any problems.
·FindResourceW(...) returns nullptr and fails if you do it on the static library side and link it to the executable.

Could you tell me the solution?
Thank you for your cooperation.

c++ visual-studio

2022-09-29 22:18

1 Answers

First, the so-called resource data in Windows is
You can embed the executable file for Windows*.exe or *.dll via link processing.

VS allows you to add resources to static library projects, but
Due to the nature of the project, the linker does not start during build, so
The completed *.res file will not be used at all (not embedded).

First of all, I'd like to ask you a question. "How to View Only Resources from Multiple Executable Files"

reinterpreted as shown in . The simplest way to do this is to embed the resource for the only DLL and
The executable file on the side that uses it uses the resource via the DLL,
I think that's what it means.

Resources within the DLL must be accessed using the instance handle of the DLL, so
It's easy and common to have a function to provide the DLL with that resource.


2022-09-29 22:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.