Reputation: 985
I'm struggling to find any helpful resources on how I can use the resource section within a executable to store and retrieve data.
If anybody would be kind enough to explain it and possibly provide some sample code, I would be most grateful.
Edit - Working with Windows Visual c++ 2008.
Upvotes: 0
Views: 633
Reputation: 9388
There is a portable way to encode files in an executable: you encode your files in specific structure. Ex:
// header MyFile.h
static const int fileSizeInBytes = 42;
extern const unsigned char myFileContents[fileSizeInBytes];
// source MyFile.cpp
const unsigned char myFileContents[fileSizeInBytes] =
{
0x0A, 0x35, 0x25, //...
// ...
0xAB, 0xCD, 0xEF
};
You can find some tools for automatically generating those files (for example, with Qt, there is rcc).
Also, there is a more specific answer here (Windows, PE format). You can also look here (although it's for the Irrlicht Engine, the code is rather clear and small, easily understandable) (still for PE format). I don't know for the ELF format.
Upvotes: 1