I have a string table defined like this in my Win32 app:
STRINGTABLE
BEGIN
IDS_STRING101 "myString1"
IDS_STRING102 "myString2"
IDS_STRING103 "myString3"
END
Since I want all of these strings to be part of an array, is it possible to iterate through this table? Since LoadStringA() requires the macros IDS_STRING101 etc., it seems impossible to iterate through it.
For a practical example, how would I programatically move these strings to an array of strings (char* array in C, std::string array in C++) without using the obvious way of writing a long repetitive code of LoadStringA() calls with the second parameter IDS_STRINGXXX? If possible, I want to be able to add more strings to this table in the future without modifying anything in the code.
There is no API to enumerate through the individual strings of a string table. You would have to load the entire string table resource as a whole into memory and then parse it manually per the documentation.
A simpler solution would be to just call LoadStringA() in a loop, since your string IDs are sequential, eg:
char myStrings[3][16] = {};
for (int idx = 0; idx < 3; ++idx) {
LoadStringA(hInstance, IDS_STRING101 + idx, myStrings[idx], 16);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With