I dont want to store the plain bitmaps as files in a directory where the
EXE is located, to prevent them being mangled or replaced by end-users.
Does anyone have any good ideas or tips on how I would securely "pack"
the bitmap files (various sizes and color depths) all into one large
disk file (e.g. "data.dat") and then extract them by name from my code
at run time? There are several way I can think of doing this, but was
wondering if anyone has any preferences or ideas about where I should
start with this.
The approach I use is to embedded them directly into the exe. Every windows
exe can have "resources" packed/added to the exe, these resources are
usually icons, cursors, bitmaps, string tables and other data.
Once you've added your resources to the exe, extracting them is easy - just
use the standard Win32::GUI constructors (As a default they always look in
side your exe). For example, I have the following code:
#load in main icons
$icon = new Win32::GUI::Icon('APP');
$icon = new Win32::GUI::Icon(cwd.'\Art\App.ico') unless $icon;
The first line tries to extract an icon resource called 'APP' from the exe,
if it doesn't exist (such as when you are running via Perl) it returns undef
which then causes the second line to load the icon from the file system.
There are several ways to add resources to your exe, I use Resource Hacker a
free utility that can also be run via the command line (so you can make it
part of your build process):
http://www.angusj.com/resourcehacker/
Adding resources works for both Perl2exe and PerlApp, but I think you might
have to add resources to Parl.exe (or what ever its called) rather than the
end exe that PAR produces. There may be posts about it on the Par mailing
list.
Cheers,
jez.