3

I am trying to get string resource length with FindResource/SizeofResource functions.

I make call like this:

HRSRC hResInfo = FindResource(hModule, MAKEINTRESOURCE(resourceId), RT_STRING);

I receive NULL and GetLastError returns ERROR_RESOURCE_NAME_NOT_FOUND.

Now I use the same variables to make following call:

LoadString(hModule, resourceId, buffer, 4096)

And string is loaded successfully with the same hModule and resourceId.

So, I can load string resource, but can not find it with FindResource. What may be the reason? How to find string resource with FindResource (and hence get its size)?

Alex K.
  • 171,639
  • 30
  • 264
  • 288
Vitalii
  • 4,434
  • 4
  • 35
  • 77
  • 4
    FindResource w/ RT_STRING is not as simple as that as they are stored in blocks; see http://stackoverflow.com/questions/6720259/how-do-you-open-a-resource-string-in-visual-c-2010 – Alex K. Sep 21 '12 at 15:19
  • 2
    Just to clarify, the string identifiers are NOT the same as the resource ID. – Deanna Sep 21 '12 at 15:25
  • As others pointed out, `RT_STRING` gets you `STRINGTABLE` resource, and not individual string. See http://blogs.msdn.com/b/oldnewthing/archive/2004/01/30/65013.aspx – Roman R. Sep 21 '12 at 15:45
  • Thanks, friends, I see now how to get what I want. – Vitalii Sep 21 '12 at 18:19

0 Answers0