[Lazarus] Extracting a resource from an exe file & adding it back in

Reinier Olislagers reinierolislagers at gmail.com
Sat Oct 15 14:26:39 CEST 2011


Hi list,

I've created a zip file with some files in it, then compiled these as a
(Windows x86) resource using this .rc script:
// Configuration file for
// executable files required by checkride
//fields: resource name/resource type/resource filename

//all compressed in one zip:
ALL          CR_EMB_FILE helped.zip

(Created my own resource type because that seemed the only way)

I want to give users an editor to edit a text file inside helped.zip &
save the changes back to the executable.

Therefore, I'm looking for a way to extract the compressed resource to a
zip, extract the zip, let the user edit the file, zip it back up and add
it back into the executable.

1. Can I load the exe into a stream and then copy that over to a
TResourceStream? If so, I can do the extracting/editing.
2. I suppose I'd have to call windres.exe to extract the .rc file from
the resource*) & compile the zipped resource back into the exe. Can I do
that & overwrite the exiting resources in the exe?
3. Is there a better way to do all this?

*) Of course, I have the resource .rc file in my source directory, but
perhaps the user wants to edit a different version of my program that
has other resources...

Of course, I could try out 1 & 2, but if you guys have an answer to step
3, that may be work down the drain...

Thanks a lot,
Reinier




More information about the Lazarus mailing list