I do this in some of my code.
You can embed the data into resources of the .exe file. To do this, all of the "to be embedded" files need to exist when the .exe is built. Add the files as resources to the enclosing .exe file (you asked about C++ and MFC; the process is a little different for .NET). To do this, add each file as a line item in the .rc or .rc2 file, just as you do with bitmaps and icons:
IDR_MAINFRAME ICON "blahblah\\icons\\blahblah.ico"
IDR_FILE_RELEASENOTES HTML "blahblah\\text\\blahblah_releasenotes.htm"
IDR_FILE_PARAM FILE "blahblah\\paramdata\\PARAMS.XML"
IDR_FILE_TEST FILE "blahblah\\paramdata\\TESTDATA.DAT"
Here is the code I use to extract the data to a file (when my program runs):
bool CreateFileFromResource(char const* sFilename, HMODULE hInstance, WORD resourceID)
{
bool bRetval = false;
HANDLE hFile = CreateFile(sFilename, GENERIC_READ | GENERIC_WRITE,
0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
_ASSERTE(hFile);
if(hFile)
{
_ASSERTE(hInstance);
HRSRC hResource = FindResource(hInstance, MAKEINTRESOURCE(resourceID), "FILE");
_ASSERTE(hResource);
if(hResource)
{
HGLOBAL hFileResource = LoadResource(hInstance, hResource);
_ASSERTE(hFileResource);
if(hFileResource)
{
LPVOID lpFile = LockResource(hFileResource);
_ASSERTE(lpFile);
if(lpFile)
{
DWORD dwSize = SizeofResource(hInstance, hResource);
HANDLE hFilemap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwSize, NULL);
LPVOID lpBaseAddress = MapViewOfFile(hFilemap, FILE_MAP_WRITE, 0, 0, 0);
CopyMemory(lpBaseAddress, lpFile, dwSize);
UnmapViewOfFile(lpBaseAddress);
CloseHandle(hFilemap);
bRetval = true;
}
}
}
CloseHandle(hFile);
}
return bRetval;
}
I also have code to extract the contents of an embedded resource (usually xml) into a string or a DOM which I'm sure you can figure out from the above.
As I said above, this code works in a native C++/MFC environment (ie. if you build a RES file). The concept is the same but with different details in .NET (ie. if you use a .RESX file).