[fpc-pascal] Reading resources

Juha Manninen juha.manninen62 at gmail.com
Sun Jul 19 19:24:39 CEST 2015

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 :

  Res.LoadFromFile(AFileName, Reader);

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

  ResItem: TAbstractResource;
    if ResItem is TVersionResource then
      LoadVersionResource(ResItem as TVersionResource)
    if ResItem is TBitmapResource then
      LoadBitmapResource(ResItem as TBitmapResource)
    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.


More information about the fpc-pascal mailing list