I want to put an exe file in my C++ program, but I don't understand how to do it. I am using Visual Studio 2019. I know that it can be done through project resources, but I don't know how to work with it.
Asked
Active
Viewed 70 times
-4
-
Why not just put it in the same directory as the 'parent' program and run it from there? That's the usual way (and you provide your users with an installer that puts it in the right place). – Paul Sanders Jun 27 '22 at 19:50
-
The notion of resources is implementation specific. [This C++ reference](https://en.cppreference.com/w/cpp) don't mention them. – Basile Starynkevitch Jun 27 '22 at 19:51
-
I recommend using an *installer* to add additional files, like exe's, to your deliverable. – Thomas Matthews Jun 27 '22 at 19:52
1 Answers
3
Create an .rc
file to refer to the desired embedded .exe
as an RCDATA
resource, eg:
MYEXE RCDATA "path\to\file.exe"
Add the .rc
file to your project.
The referred .exe
file will then be compiled into your final executable.
You can then access the MYEXE
resource at runtime using the Win32 FindResource()
/LoadResource()
/LockResource()
functions, or higher-level framework equivalent.

Remy Lebeau
- 555,201
- 31
- 458
- 770