Normally, in order to extract files from a Zip archive file, you need a program such as PKUnzip or a program created with Abbrevia that knows how to handle the Zip file's contents.
Self-Extracting Zip files, however, do not require a separate program to unpack the files they contain. Instead, Self-Extracting Zip files are a combination of the Zip archive file's data and a small program, called a stub, that handles the file extraction automatically. Because Self-Extracting Zip files are programs (they have an EXE extension), users can de-compress their contents simply by executing the archive file itself.
...you might want to customize our stub program to display your company logo or show contact information.
Self-Extracting Zip files are useful in a number of situations. For simple program installations, for example, Self-Extracting Zip files offer an easy and efficient way to distribute data without having to provide (and explain the use of) a separate decompression tool.
Abbrevia fully supports the creation of Self-Extracting Zip files. In fact, Abbrevia comes with simple stub programs that you can use as starting points for your own more elaborate stubs. For example, you might want to customize our stub program to display your company logo or show contact information.
In this Step-By-Step article you'll see exactly how to create a self-extracting Zip archive EXE from an existing Zip archive file.
- Create an executable stub file by opening one of Abbrevia's of the example stub projects, SELFSTUB or SELFSTBV located in the examples directory and compiling it. The executable stub file is that part of the self-extracting archive that performs the decompression. When it's compiled, close the project.
- Start a new project in Delphi. Using the Object Inspector set the form's Caption property to 'Self Extracting Zip Example'. Set the form’s Height property to 120 and its Width property to 343.
- From the Dialogs tab in Tools Palette, add a TOpenDialog to the form.
- Add a TButton to the form and create the following event handler for the OnClickEvent:
procedure TForm1.Button1Click(Sender: TObject); begin if AbMakeSelfExe1.Execute then ShowMessage(AbMakeSelfExe1.SelfExe + ' has been created'); end;
- Add a TAbMakeSelfExe to the form and create the following event handlers for the OnGetStubExe and OnGetZipFile events, respectively:
procedure TForm1.AbMakeSelfExe1GetStubExe( Sender: TObject; var aFilename: String; var Abort: Boolean); begin OpenDialog1.Title := 'Select executable stub'; OpenDialog1.Filename := ''; OpenDialog1.Filter := 'Exe files|*.exe'; Abort := not OpenDialog1.Execute; if not Abort then aFileName := OpenDialog1.Filename; end; procedure TForm1.AbMakeSelfExe1GetZipFile( Sender: TObject; var aFilename: String; var Abort: Boolean); begin OpenDialog1.Title := 'Select Zip File'; OpenDialog1.Filename := ''; OpenDialog1.Filter := 'Zip files|*.zip'; Abort := not OpenDialog1.Execute; if not Abort then aFileName := OpenDialog1.Filename; end;
- Compile and run the application.