5

What it the best way to find out if a resource name exists - other than seeing if

LoadFromResourceName (HInstance, 'FOOBAR')

causes an exception?

RRUZ
  • 134,889
  • 20
  • 356
  • 483
rossmcm
  • 5,493
  • 10
  • 55
  • 118
  • This is a duplicate and has been asked many times before. For example [How do I check if an embedded resource exists or not?](http://stackoverflow.com/questions/9744979/how-do-i-check-if-an-embedded-resource-exists-or-not) – David Heffernan Jul 31 '12 at 09:01
  • @David That's what I figured, but I would have expected those solutions to be served up as I was entering my question (Delphi's help for `LoadFromResourceName` wasn't much help either, but it never is. They seemed to have abandoned to idea of hyperlinks to other related useful topics in D2006). – rossmcm Aug 01 '12 at 08:41
  • SO search is notoriously flaky. I found the dupe with a google search. But I also searched on `FindResource`. It's easy to find dupes once you know the answer! No worries! – David Heffernan Aug 01 '12 at 08:47
  • Possible duplicate of [How do I check if an embedded resource exists or not?](https://stackoverflow.com/questions/9744979/how-do-i-check-if-an-embedded-resource-exists-or-not) – saastn Oct 15 '17 at 08:31

1 Answers1

10

You can use the FindResource function (remember pass the proper resource type)

 if FindResource(hInstance, 'FOOBAR', RT_RCDATA) <> 0 then
  // do something
RRUZ
  • 134,889
  • 20
  • 356
  • 483