Archived

This topic is now archived and is closed to further replies.

!! LoadString problem !!

This topic is 6162 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?????

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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)

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites