Sign in Join
Wiki copytemporary

Revision 2 of 2, by Trev on 8-13-2020. The page as it is now.

lazres

Note: Since Lazarus v1.4.0, Lazarus has switched to .res format instead of .lrs; see Lazarus 1.4.0 release notes.
To create .res resource files you can use either lazres or winres

lazres is a lazarus resource tool to create and convert .rc, .lrs and .res files.

Lazres can be found as <root>/lazarus/tools/lazres.lpi and might need to be compiled. In Ubuntu installations lazres is precompiled and available in /usr/bin

text
Usage: lazres resourcefilename filename1[=resname1] [filename2[=resname2] ... filenameN=resname[N]]
       lazres resourcefilename @filelist

To create a resource file MYRES.RES with two .bmp graphics files use:

text
lazres MYRES.RES MyImage1.bmp=IMG1 MyImage2.bmp=IMG2

A resource file can be of type:

.RC resource description file plaintext
.LRS lazarus (pascal) resource plaintext
.RES compiled resource binary default

Using resources

.lrs

Include .lrs file in the initialization section

pascal
initialization
  // .LRS files are plain-text pascal statements and need unit LResources to be included in the Uses clause
 {$I MyResources.lrs}
end.

.res

Load .res file in the implementation section

pascal
implementation
  // .RES files are binary resources and can be loaded
  {$R MyResources.res}

var 
  img: TImage; 
begin
  img.Picture.Bitmap.LoadFromResourceName( hInstance, 'IMG1' );
end;

See also


From the Free Pascal wiki, page "lazres", as it stood on 2020-08-13 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.