views:

136

answers:

6

I have a requirement to build an Image manager which will allow users to build a collection of photos/images and then give them an option to convert these photos to a single EXE which when run, will show the photos/images on target PC as a slide show in full screen.

Is it possible to do this for multiple images?

+5  A: 

Should be possible. What you'll have to do is a EXE framework (stub) that reads its own binary and checks for an appended image list (can be something simple like [number of images][image sizes][image_1]...[image_n]) and displays those in a slide show.

You can then concatenate the EXE stub, the image information and the images for your final slide show EXE.

Searching for the end of the EXE file (beginning of the image list) is usually done by using a constant header that does not appear in the EXE file, knowing the size of the stub EXE or writing the image list offset at the end of the EXE file. Alternatively, you can store the information the other way round and start reading from the end of the file.

Here is something that looks like a good link for stub example code.

schnaader
Resources would be a good way to store the images. You can use the Windows API to retrieve them too.
mj2008
@mj2008, Resources require recompiling the exes OR using hackish techniques to change the resource post-compile. The OP wants to build an slideshow, the stub exe + appended-something is infinitely better. +1.
Cosmin Prund
Hackish? Appending anything to an exe is infinitely more hackish. Updating a resource is updating exe checksum and more "stuff" in the PE header.
wqw
A: 

this can be also a solution:

http://www.delphi3000.com/articles/article_2606.asp?SK=

best regards,

Radu Barbu
+2  A: 

IrfanView can allready do that:
http://www.irfanview.com/
It can even unpack them from the exe-file again.

BennyBechDk
+1 Don't write new software if you can use good quality existing free software (which I assume this is, I haven't used it myself!)
MarkJ
Using Irfan View is news for me. I will check it. Thanks for hint!
Yogi Yang 007
A: 

You can build an application that enumerates its' own resources and loads them for display; this one the end users will run for the slide show. A separate app could add the user-selected resources to the first one. See the MSDN documentation for UpdateResource for info on adding the resources, and EnumResourceNames for information on enumerating them.

Ken White
A: 

If you decide to write your own, be aware that writing or modifying an .exe (or any file in C:\Program Files, etc.) is prohibited on many computers these days due to concerns about malware.

You should carefully test your solution as a non-Administrator on many different configurations...

Robert Frank
I am quite aware about this. Thanks for the hint though!
Yogi Yang 007
A: 

We provided some free and open source classes to read a .zip archive bundled (or not) to an exe. You can therefore append any .zip archive to your exe, then extract any picture inside this .zip with one class.

Use the following method:

constructor TZipRead.Create(const aFileName: TFileName; ZipStartOffset, Size: cardinal);

and provide paramstr(0) - i.e. your exe - as aFileName and ZipStartOffset as a minimal original exe size: it will search for the beginning of the .zip file from this offset. Leave Size parameter as 0: it will get the size from the file size itself.

The same class can get any .zip archive embedded as a resource to your exe, if you prefer.

They are two ways of appending .zip content to an exe:

  1. use copy /b original.exe+pictures.zip newembedded.exe
  2. use the TZipWrite class provided, and its AddFromZip() method to create your exe from Delphi code: you can even compress and append your images on the fly, with no temporary pictures.zip file.

See http://synopse.info/forum/viewtopic.php?pid=163

A.Bouchez