Link to home
Start Free TrialLog in
Avatar of rpetruni
rpetruni

asked on

Resource files

Hi all,

i know how to make dll, and how to use functions and procedures in it, but i want to make dll ONLY with resources (like bitmaps, icons, waw's  etc.).
I know how to make dll, but i don't know how to USE those resources in it..
Please help
Avatar of viktornet
viktornet
Flag of United States of America image

You simply need to load it just the way you do, and pass the handle LoadLibrary() to the LoadBitmap() for example which would load the bitmap from the DLL...

..-=ViKTOr=-..
Avatar of rpetruni
rpetruni

ASKER

Hi Viktornet,

you think something like that?

procedure TForm1.Button1Click(Sender: TObject);
var
   il: THandle;
begin
     il:=LoadLibrary('NameOfMyDll.dll');
     if il<32 then
     begin
           ShowMessage(IntToStr(GetLastError()));
     end;
     Image1.Picture.Icon.Handle:=LoadIcon(il, PChar('3'));
     Image2.PictureBitmap.Handle:=LoadBitmap(il, PChar('5'));
     FreeLibrary(il);
end;

What i get with this code is:
1. Nothing in those Images :o)
2. Error message when i close an application "Invalid handle to the pointer" ???
Any idea?


Ooooooooooops,

1. Nothing in image 1 (traying to load an icon),
Image2 is ok ... ???

Ok, i foud out something more...

I cut and paste the above code to a new project and tehre is no more error ......

So my Q is ...

How to load an icon -  Image1.Picture.Icon.Handle:=LoadIcon(il, PChar('3'));
does NOT work - or am i missing something?

How to load WAW or similar files?
I will increase the points if sombody has a really good answer (like two or three lines of code ;o)
                                                                        Robert
For icons, use:

...Icon.Handle := LoadIcon(il, MAKEINTRESOURCE(3));

For bitmaps, use

bmp.LoadFromResourceID(il, 3);

Cheers,
Phil.


ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For waves and the like, do something like this:

var hRes: HRSRC;
    gobj: HGLOBAL;
    p: Pointer;
begin
  hRes := FindResource(il, MAKEINTRESOURCE(3), RT_RCDATA);
  gobj := LoadResource(il, hRes);
  p := LockResource(gobj);
  //p is a pointer to your resource data

  ...

Cheers,
Phil.
 
whoops should've done a refresh <blush>
Yeah, me too. I didn't see your answer! ;-)
Avatar of simonet
Barry's got the correct answer. The site he pointed is actually the best resource on the net about resources (forgive the pun!). I have no affiliation to the site he pointed you to, but I just happen to know the guy to created that site (he's a nice fellow, by the way).
The URL Barry gave you is undoubtly a perfect answer to the question. ;)
>>I have no affiliation to the site  

           :o)
Just for the drama effect, like those folks that sell stuff on TV.
Yep, the site is really good...
And the info in this zip is much more than i asked for...
Thks