EXT Resources Library - string

The res::string class provide an array-like access to PE string resources similar to simple LoadString API call.


Set langid to language identifier of the prefered language. The res::string uses the res::lang to search among available string mutations. Set hInst to handle of a loaded module that contains the string resources. NULL specifies the process executable.

The res::string class provide following interface:

class string {
        string (void * hInst = NULL, unsigned int langid = 0) throw ();
        ~string () throw ();

        const std::wstring operator [] (unsigned int id) const throw ();

Use the .operator [] () and provide a numeric identifier of the string. The function returns std::wstring object containing the string loaded from the resources. If no such string (of provided identifier) exists, an empty string is returned.

You will need to include "ext/res_bits/string.cpp" into your project in order to use res::string.


#include <windows.h>
#include <ext/res>

int main () {
    res::string string;

    printf ("%ws\n", string [123] .c_str ());
    printf ("%ws\n", string [124] .c_str ());
    printf ("%ws\n", string [125] .c_str ());

    return 0;


Although the res::string returns wide-character strings, it can be safely used in software that is expected to work on Windows 95/98/Me operating systems. You may use the ext::echo if conversion to std::string is required.

Note that string resources are stored in blocks of 16 strings. This may result in confusions when fallback to neutral language versions is expected when localized version is missing. See MSDN for more on this topic.