Is there a way to add files to the final .exe in a c++ program ?
For example, suppose I want to play a sound file. Instead of including the sound file separately with the release .exe, the file should be part of the exe.
Im aware about the use of resource files, in C++. This article on the MSDN website, says that it is possible to use resources in Visual C++. Can I also use them on Eclipse, with MinGW ? Please also explain how to use them.
Is there a way to add files to the final .exe in a c++
Share
Suggestion:
Actually, the easiest way is to simply append the binary contents to the end of the .exe. Append a 4-byte “length” value after that. It will not affect your ability to run the .exe. Then, at runtime:
1) Open your .exe as a binary file, read-only.
2) fseek (or equivalent) to .exe size – 4.
3) read the length
4) fseek to exe size – length – 4
5) read the binary file
This works for DOS, Windows and Linux files.