I am on Visual Studio 2022, and I have a project built with a C++ code.
The code looks for a data file "C:/MyData/data.dat", and the absolute path "C:/MyData/data.dat" is written in the .cpp source code.
I would like to incorporate the file data.dat into the .exe file (to make it self-contained and portable) and tell the exe file to look for data.dat ‘inside itself’. How may I do this? With what should I replace "C:/MyData/data.dat" in the .cpp file.
Thank you
2
Answers
You have a) to add the resource in a .RC file, for example
and b) to Load it at runtime with FindResource and LoadResource and LockResource and SizeOfResource.
You should be able to read the embedded file using
io
.E.g.
Convert void* to char*
main.cpp
resource.h
resource.rc