Hey, people.
I'm quite a novice Lazarus programmer, and I would like a bit of help, please. How do I use Lazarus resources?
I think I know what they are, files that can be compiled into the binary? I'm not sure, but it was suggested to me when I asked how an installer works. Problem is, I can't find 'New Resource' in Lazarus, and I have no idea how to use it anyway. I Googled it but can't find it anywhere. I'm going to attempt to write an installer that installs a dummy .exe on the computer. Any help would be appreciated,
- Josh
Mailing lists / lazarus / 2010-07
Lazarus Resources
21 messages · 10 people · –
- JJosh Lee 8
- AAntônio 2
- HHans-Peter Diettrich 2
- MMattias Gaertner 2
- PPaul Ishenin 2
- DDuncan Parsons 1
- +4 more
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
You can compile it with GoRC.EXE (you can find it on FPC folder) and link it through the directive {$R resname.res} on your project.
Ant?nio
2010/7/20 Josh Lee :
Show quoted text 16 lines
I know these look like spam, I'm not that familiar with mailing lists... Could someone please give me a description and documented code explaining on how Lazarus Resources works and how to use it to make a stand alone .exe that transfers files to the hard drive? I really need to know, as I wish to craft a simple installer. To clarify: I want to craft my OWN installer, not some installer building software.
- Josh
I am now very confused. I have been told by someone on Lazarus Forums that to write an installer, I would need to use Resources. I have done some research into resources, and got this:Resource (Windows)From Wikipedia, the free encyclopedia In Microsoft Windows, resources are read-only data embedded in EXE, DLL, CPL or (beginning with Windows Vista) MUI files. The Windows API provides for easy access to all applications' resources. [edit]TypesEach resource has a type and a name, both being either numeric identifiers or strings. Windows has a set of predefined resource types:
Cursor and animated cursorIconBitmapDialog box templateFontHTML documentString and message templateVersion data--------------------------------------------------------- So it seems that I cannot store a FILE in a resource. All I wish to do is make a simple installer that installs an .exe onto the user's hard disk. Thank you for the link, Mattias. It seems the page has been updated since I last saw it. This is the code for my installer so far:procedure TMainForm.InstallButtonClick(Sender: TObject);beginStatusMemo.Append('Attempting to retrive file...');CRes := LazarusResources.Find('test');StatusMemo.Append('test resource found.');{So what do I do here to get the .exe stored in the resource(Compiled with Lazres) and place it on the users hard disk?}... Do I have some mislead conception of a 'resource'?What comes next in the code?Thanks in advance,- JoshPS. Sorry for the repeated posts, I'm having time lag and I'm posting from a crappy device
_________________________________________________________________ http://clk.atdmt.com/UKM/go/195013117/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100725/0f56e4ad/attachment-0001.html>
Show quoted text 11 lines
If you followed the wiki page you now have the file in a string. Now save the string to a file and set the file attributes.
Do I have some mislead conception of a 'resource'?What comes next in the code?Thanks in advance,- JoshPS. Sorry for the repeated posts, I'm having time lag and I'm posting from a crappy device
Mattias
Josh Lee
Programmer - Owner of JLSoftware
Mattias Gaertner wrote 23 lines
Right, so if I followed the Wiki, Data would contain a string? What would the string be? Can resources only contain one piece of data?
What would saving a string to a file accomplish?
I have only been writing in Lazarus for half a year, and have no expertise in file I/O.
I am now very confused. I have been told by someone on Lazarus Forums that to write an…
Each resource has a type and a name, both being either numeric identifiers or strings.
[...]
So it seems that I cannot store a FILE in a resource.
You can add files as User-Defined resource types, or use RCDATA for raw (binary) data. See MSDN "Resource Definition Statements", "User-Defined Resources".
Please quote only the relevant parts of the original message.
DoDi
You can add files as User-Defined resource types, or use RCDATA for raw (binary) data. See MSDN "Resource Definition Statements", "User-Defined ResourcesThank you, I read up on them.Do you know where I can find a step by step tutorial on how to create a stand alone program that installs something on the hard disk?Or sample code I can build up on?Thanks.> Please quote only the relevant parts of the original message.
Sorry.- Josh
_________________________________________________________________ http://clk.atdmt.com/UKM/go/197222280/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100725/4b1153e4/attachment.html>
Do you know where I can find a step by step tutorial on how to create a stand alone program that installs something on the hard disk?
No sorry. Details depend on what you want to install (files only, registry settings...), if you want to add an uninstall option as well, etc.
I don't know whether MS released according documentation, because they provide their own tools for that purpose - so they most probably describe only how to use these.
Or sample code I can build up on?
Some open source installer?
DoDi
Sorry.- Josh _________________________________________________________________…
From: Josh Lee [mailto:]
Sent: 25 July 2010 12:11
> You can add files as User-Defined resource types, or use RCDATA for
raw
> (binary) data. See MSDN "Resource Definition Statements",
"User-Defined
> Resources Thank you, I read up on them. Do you know where I can find a step by step tutorial on how to create a
stand alone program >
Show quoted text 6 lines
InnoSetup is a fabulous installer for windows, and worth a look: http://www.jrsoftware.org/isinfo.php You can get the latest source via CVS. It'll be complicated to look through, but I'm sure you'll find some of what you're looking for. Last time I looked through the source for it was about 8 years ago, so it will have grown a bit since then... NB it's Delphi code, with some hacks that might not be fully compatible with FPC, but you should be OK reading it.
Once you get the hang of them, resources are pretty easy - I'm sure you'll be fine :-)
HTH
DSP
Show quoted text 10 lines
Yesh thank you, looking through the source is very educational. I love the idea that they implemented Pascal in it, so you can make custom scripts! It's like a non-GUI Lazarus ;) But isn't Delphi resources set out different from Lazarus resources? The first thing I'm going to do when I fully understand Lazarus resources is write an article on it, explaining how to do what I'm trying to do. :)
Josh Lee wroteYesh thank you, looking through the source is very educational. I love the idea that they implemented Pascal in it, so you can make custom scripts! It's like a non-GUI Lazarus ;) But isn't Delphi resources set out different from Lazarus resources?
Delphi uses Windows resources though the Windows API
Lazarus supports 2 kinds of resources: Windows resources (RC files) and Lazarus resources (LRS files) using FPC/Lazarus APIs
In that sense looking at the Inno Setup source code probably won't help much as it will probably be using Windows API which aren't portable.
Felipe Monteiro de Carvalho wroteIn that sense looking at the Inno Setup source code probably won't help much as it will probably be using Windows API which aren't portable.
FPC resources api is compatible with windows.
Best regards,
Paul Ishenin.
Zitat von Paul Ishenin :
Show quoted text 5 lines
Can you add some links or paragraphs on
http://wiki.lazarus.freepascal.org/Lazarus_Resources
about the new resources?
Mattias
Josh,
You can store a resource file on your exe by compiling a resource from a file via this tool ( http://lazarusbrasil.org/Resources.zip ) and adding the line {$R ResName.res} to your project.
Then you can call the resource by name so:
var
ResStr :TResourceStream;
begin
ResStr := TResourceStream.Create(hInstance, ResName, ResType);
try
ResStr.SaveToFile(FileName');
finally
ResStr.Free;
end;
end;Ant?nio wrote 25 lines
Thank you so much, this is exactly what I needed! :)
Zitat von Paul Ishenin : Can you add some links or paragraphs on…
Mattias G?rtner wroteCan you add some links or paragraphs on http://wiki.lazarus.freepascal.org/Lazarus_Resources about the new resources?
Done.
Best regards,
Paul Ishenin.
Show quoted text 8 lines
Thanks.
Mattias
Done. Paul Ishenin.
Paul Ishenin wrote 8 lines
Oh brilliant, thanks so much. The article has a lot more information now.
Dear sirs:
i have been advised to subscribe a spanish list in addition to this one,
i will appreciate very much if you can tell me the email address of that list,
thanks in advance,
yours truly,
Ing. H?ctor F. Fiandor Rosario
All the public mailing lists:
http://lists.lazarus.freepascal.org/mailman/listinfo
2010/8/17 hector fiandor :
