Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-07

Reading resources

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

Lazarus examples folder has an application ResExplorer made by Alexey Lagunov. It does not work well, images and other resource contents are not shown. Only the resource name shows correctly.
It uses FPC resource classes. How to use them properly? I am testing now with FPC trunk but 2.6.4 works the same way.

Simplified code when a Windows executable is read :

  Reader:=TWinPEImageResourceReader.Create;
  Res:=TResources.Create;
  Res.LoadFromFile(AFileName, Reader);

The items (TAbstractResource) of "Res" are stored in a TreeView and later shown when nodes are clicked :

var

  ResItem: TAbstractResource;

...

    if ResItem is TVersionResource then
      LoadVersionResource(ResItem as TVersionResource)
    else
    if ResItem is TBitmapResource then
      LoadBitmapResource(ResItem as TBitmapResource)
    else
    if ResItem is TGroupIconResource then
      LoadGroupIconResource(ResItem as TGroupIconResource)

The problem is that TBitmapResource never happens, although most of the resources contain images.
ResItem is TGenericResource then.

LoadGroupIconResource does happen but viewing it is not implemented. TVersionResource is the only one that really shows.

I have an idea to make a proper resource manager application supporting reading, writing and modifying both FPC *.res and the old Lazarus *.lrs resources. This ResExplorer would be a good starting point if only it worked.
Is there such code already somewhere? I don't want to do duplicate work.

Regards,
Juha

Reply by email

Bart
to Juha Manninen
Juha Manninen wrote
This ResExplorer would be a good starting point if only it worked.

A bit off-topic, but you noticed the spurious memory leaks in the example program?

Heap dump by heaptrc unit
9055 memory blocks allocated : 2926212/2955096
8023 memory blocks freed : 2901453/2928496
1032 unfreed memory blocks : 24759

Bart

Reply by email