C++ Resource file strings

harsha_james
harsha_james used Ask the Experts™
on
Hi,
I am using a resource file in my c++ DLL to store some strings. I have used the 'STRINGTABLE' type. Now, I am able to get the string from the DLL using the 'Loadstring' function.
My requirement is as follows:
The number of strings in the STRINGTABLE can vary. Now, before getting the strings from the DLL, I want to get the total number of strings in the DLL resource file's STRINGTABLE. Is there any function like 'Loadstring' that gives us the number of strings in the file?

Also, is there a function with which I can read all the strings together in one go?

Thanks in advance for your suggestions,
Warm regards,
hj
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Deepu AbrahamR & D Engineering Manager

Commented:
You could write a function to return the count and try exporting that.
Commented:
Take a look at EnumResourceNames() function.

http://msdn.microsoft.com/en-us/library/ms648037%28VS.85%29.aspx
jkr
Top Expert 2012
Commented:
Unfortunatly, there is no such function that would satisfy all your needs, see http://msdn.microsoft.com/en-us/library/ms674841(VS.85).aspx ("Resource Functions"). A simple workaround might be to read all of them and count them while doing so in a loop (with the prerequisit being that the string IDs are in a consecutive order), e.g.
#include <tchar.h>
#include <string>
#include <list>
using namespace std;
typedef string<TCHAR> tstring;

UINT nID = 0;
TCHAR acBuf[MAX_SIZE];

list<tstring> lStrings;

while(!LoadString(hDll,nID++,acBuf,MAX_SIZE))
  lStrings.push_back(acBuf);

// now, nID holds the cound of strings, or use 'lStrings.size()'

Open in new window

Author

Commented:
Thanks a lot for your replies.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial