Announcement

Collapse
No announcement yet.

Get resource type using only the resource name?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get resource type using only the resource name?

    Is there any way to determine what "type" an object in a resource file from just the resource name?

    For example, my resource file has these two objects defined:

    Code:
    PROGRAM ICON home.ICO
    TITLE BITMAP title.bmp
    If I only have the name (i.e. "TITLE") is there any way to determine programatically that it is a BITMAP resource type?

    Thanks,

    Anthony
    Anthony Watson, Mountain Software
    www.mountainsoftware.com

  • #2
    Wasn't there an enumresources() ?
    hellobasic

    Comment


    • #3
      >Wasn't there an enumresources() ?

      Nope.

      But....

      You can EnumResourceTypes(), then in your callback for that, do an EnumResourceNames() for that type... you'll end up with a list of all resources in the target module by name and type.

      MCM

      FWIW, this is legal
      Code:
      FOO   BITMAP  filename
      FOO  ICON      filename
      FOO  RCDATA   filename 
      FOO  DIALOG
      Can't very well ask if the resource named FOO is a bitmap, can you? There's a BITMAP FOO to be sure, but there is also an ICON FOO, a DIALOG named FOO, an RCDATA named FOO... and a boy named Sue, too.
      Last edited by Michael Mattias; 14 Apr 2009, 06:22 PM.
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Thanks Michael and Edwin!

        I saw the EnumResourceTypes on MSDN, but it would involve too much code for the simple task I'm trying to accomplish. I was hoping for a single API call or something that would give the type for a supplied resource name. I don't want to go to the trouble of enumerating all the available resources just to find the type of a single resource. It's easier just to pass the type as a variable to my subroutine.

        Thanks!

        Anthony
        Anthony Watson, Mountain Software
        www.mountainsoftware.com

        Comment


        • #5
          >that would give the type for a supplied resource name

          Not possible: For any module you can have more than one resource with any given name, all of different types.
          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            As an example, in many of Penzold's examples, he uses the program's name as the class name, the menu name, the icon name, ...
            Furcadia, an interesting online MMORPG in which you can create and program your own content.

            Comment

            Working...
            X