!! LoadString problem !!

Started by
4 comments, last by Bloodseeker 23 years, 2 months ago
How can I find out how long a string is BEFORE loading it using LoadString???? As the msdn library says, a solution to this problem only exists in Windows CE, where calling LoadString with the LPSTR parameter set to NULL returns a pointer to the string resource preceded by a word holding the length of the string. But how to handle this in Windows 9x?????
Advertisement
Do you really HAVE to use LoadString???

I used to have nothing but problems with it, until I dropped it..it used to cause some very strange behaviour in my programs..

why not put your strings in a datafile and load ''em from there??

Wazoo
Learn about game programming!Games Programming in C++: Start to Finish
Well, I want my program to be resource-based, so that I have nothing but one exe-file. That''s why I won''t start using extern data files just because of some silly strings! So, yes, I really HAVE to use LoadString.
I would suggest doing something along one of these lines:

Define some max string lenght constant, load the string into a local buffer of that size, and then check the length.

Replace LoadString with your own version, using LoadResource/LockResource, search for the terminating null.
Why do you need to make it as a resource, you could easily make it as defines if you want it in a single .exe, almost the same thing, except for bigger .exe possibly, but not if you make it as a object with your own LoadString(ID), I mean - a resource is just a defined set of bytes in the.exe anyways - or am I wrong ?
(ok, not if it is a OS dependant resource i guess)
Well, I kinda solved the problem (by dropping the idea). I put the text in a txt file an attached it to the resources.

But I can''t do it using defines, const LPSTR''s or a ''standard'' maximum length because the strings can be both just a few bytes and even up to 500 or 600 kilobytes. And i won''t allocate 600 kb for each and every string resource just because it might possibly be that big. I think Microsoft should spend a little more time on thinking about what they put "onto the table".

This topic is closed to new replies.

Advertisement