tags:

views:

628

answers:

5
+1  A: 

I would have a look at RCDATA resources. I used it to store large text files in my application.

Edit: Here is my MFC code, it should be able to give you some pointers.

CString CWSApplication::LoadTextResource(UINT nID)
{
    HRSRC hResInfo;
    HGLOBAL hResData;
    hResInfo = ::FindResource(AfxGetResourceHandle(),
            MAKEINTRESOURCE(nID),
            RT_RCDATA);

    if ( hResInfo == NULL )
    {
     return CString();
    }

    hResData = ::LoadResource(NULL, hResInfo);

    if ( hResData == NULL )
    {
     return CString();
    }

    char *data = (char*)(::LockResource(hResData));
    DWORD len = ::SizeofResource(NULL, hResInfo);
    return CString(data, len);
}
Daniel A. White
A: 

The string resources are designed to store essentially UI-related resources and messages to be shown to the user; this way an application can be internationalized switching from one DLL containing strings for language A to another DLL containing the same string IDs for another language B. I recommend to review for what purpose are you using string resources. If you intend to store large data, use a custom binary resource in the RC. Later you can interpret it as you want.

Hernán
A: 

You can embed a text file into the resource, load it and use it inside CString.

Shay Erlichmen
A: 

You need to use a custom data (RCDATA) to avoid such a limitation. Basically by using a binary field the compiler leaves your data alone and doesn't try to "massage" it. On the other hand, if you have string resources they are subject to getting merged (to conserve space, if you set that compiler option that is) and are stored in typically stored in a special section in the image. So you want to avoid all that and tell the compiler to "just store" your data. Use RCDATA, you already have sample code to extract it.

Ash
A: 

You may not use resource files for storing your lengthy strings.

Instead, you may put all your huge strings into say a XML file and read the string as and when you need. If you want NLS support you can also have language specific files.

Canopus