delphi 2006 - Is it possible to find out if a resource name exists?
Asked Answered
U

1

5

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

LoadFromResourceName (HInstance, 'FOOBAR')

causes an exception?

Uncrowned answered 31/7, 2012 at 3:15 Comment(4)
This is a duplicate and has been asked many times before. For example How do I check if an embedded resource exists or not?Selfcontained
@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).Uncrowned
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!Selfcontained
Possible duplicate of How do I check if an embedded resource exists or not?Radix
D
10

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

 if FindResource(hInstance, 'FOOBAR', RT_RCDATA) <> 0 then
  // do something
Defensive answered 31/7, 2012 at 4:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.