Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of files in a .RES

Status
Not open for further replies.

bobbie100

Programmer
Aug 29, 2003
64
GB
I am loading all the images from a .RES file by ID number using:

Code:
  for I := 0 to NUM_RES_BMP - 1 do
    FBmps[I].LoadFromResourceID(HInstance, I);

At the moment I have the separate constant (NUM_RES_BMP ) defining the number bitmaps in the .RES.

Does anyone know how to get the number of files in a .RES file, so I can get rid of this separate constant?
OR
Do I have to resort to the alternative approach of reading the files in one at a time and catching the exception when there are no more files? (I don't like relying on exceptions as part of the normal program operation).

Many thanks
Bob
 
I use: (Stripped down version)

Code:
   Temp := PChar( {Name minus .dll part} );
   LibraryID := LoadLibrary(Temp); // load resource-dll
   If LibraryID <> 0 then
   begin
      Repeat
         inc(PicID);
         If LoadString(LibraryID,PicID,strTemp,sizeof(strTemp)) = 0 then Fail := True;
         //Do stuff related to string
      Until Fail;
   end;

Note that I'm loading strings with this, but it should work for most others.
Code:
LoadString
loads the string with the name
Code:
PicID
in the library with handle
Code:
LibraryID
into the variable called
Code:
strTemp
with size
Code:
sizeof(strTemp)
and returns a 0 when it can't do it anymore.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top