Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-pcd!hpcvlx!bturner From: bturner@hpcvlx.HP.COM (Bill Turner) Newsgroups: comp.windows.ms Subject: Re: FindResource doesn't find resources Message-ID: <106580034@hpcvlx.HP.COM> Date: 19 May 89 16:58:42 GMT References: <685@maxim.erbe.se> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 26 > I'm trying to use FindResource to find a string resource. > Then I call SizeofResource to get the size of the resource. > Using it, I do a LocalAlloc to allocate a buffer. > Finally, I read the string into the buffer using LoadString. Ah, the problem is that string resources aren't like the other resources. All other resources are stored individually accessable, but string resources are packed together into 16 resource segments. I believe that what is done is that all strings are packed into the segment based on their string ID modulo 16. FindResource et al are used to get the segment resources. LoadString goes one step further and pulls the individual string out of the resource segment. There is no way that I know of* to find the length of the string resource before loading it. One possible way is to malloc a string, and if LoadString returns the maximum size, assume the string wasn't long enough; increase and try again. Once the entire string is read, realloc to the required size. (Yech!). --Bill Turner (bturner@hp-pcd.hp.com) *There is no supported way, but the format of the string resource segments is reverse engineerable...