Sign in Join

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

Mailing lists / lazarus / 2010-07

Lazarus Resources

21 messages · 10 people · –

Reply by email Subscribe to this list Your subscription

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

Josh Lee

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

Reply by email

Antônio
to Josh Lee

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
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 -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Josh Lee

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

Reply by email

Josh Lee

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>

Reply by email

Mattias Gaertner
to Josh Lee
Show quoted text 11 lines
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?}...

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

Reply by email

Josh Lee
to Mattias Gaertner

Josh Lee
Programmer - Owner of JLSoftware

Mattias Gaertner wrote 23 lines
On Sun, 25 Jul 2010 09:52:08 +0100 Josh Lee wrote: > > 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?}... 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

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.

Reply by email

Hans-Peter Diettrich
to Josh Lee: 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

Reply by email

Josh Lee
to Hans-Peter Diettrich
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>

Reply by email

Hans-Peter Diettrich
to Josh Lee
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

Reply by email

Duncan Parsons
to Josh Lee: 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
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

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

Reply by email

Josh Lee
to Duncan Parsons
Show quoted text 10 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 :-)

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. :)

Reply by email

Felipe Monteiro de Carvalho
to Josh Lee
Josh Lee wrote
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?

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

Reply by email

Josh Lee
to Antônio
Ant?nio wrote 25 lines
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; -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Thank you so much, this is exactly what I needed! :)

Reply by email

hector fiandor
to Josh Lee

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

Reply by email

Luis R. Hilario B.
to hector fiandor

All the public mailing lists:
http://lists.lazarus.freepascal.org/mailman/listinfo

2010/8/17 hector fiandor :

Show quoted text 36 lines
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 _______________________________________________ > > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/ -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email