iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Create a Stub Program to support Self-Extracting Archives

106 8
< Continued from page 1

How to Create a Stub Program to support Self-Extracting Archives

Here's the full source code to a sample STUB program. Download the heavily documented version.

~~~~~~~~~~~~~~~~~~~~~~~~~
program SelfStub;
{$DEFINE BuildingStub}

uses
   AbArcTyp,
   AbUnzPrc,
   AbUtils,
   AbZipTyp,
   Dialogs,
   SysUtils;

type
   THelper = class
   public
     procedure UnzipProc(Sender : TObject; Item : TAbArchiveItem; const NewName : string) ;
   end;

var
   ZipArchive : TAbZipArchive;
   Helper : THelper;
   PWord: string;
   Entered: Boolean;

procedure THelper.UnzipProc(Sender : TObject; Item : TAbArchiveItem; const NewName : string) ;
begin
   if (Item.IsEncrypted) and (Entered = False) then
     begin
       PWord := InputBox('PCB Zip-Archive Is Password Protected', 'Archive created by PCB Zip' + #13#10 + #13#10 + 'Enter password:' + #13#10 + #13#10 + 'NOTE that PCB Zip ASSUMES that all files were' + #13#10 + 'archived with the same password!!!','') ;
       Entered := True;
     end;
   ZipArchive.Password := PWord;
   AbUnzip(Sender, TAbZipItem(Item), NewName) ;
end;

begin//program starts here
   Entered := False;
   PWord := '';
   ZipArchive := TAbZipArchive.Create(ParamStr(0), fmOpenRead or fmShareDenyNone) ;
   ChDir(ExtractFilePath(ParamStr(0))) ;

   Helper := THelper.Create;
   try
     ZipArchive.Load;
     ZipArchive.ExtractHelper := Helper.UnzipProc;
     ZipArchive.ExtractFiles('*.*') ;
   finally
     Helper.Free;
     ZipArchive.Free;
   end;
end.


~~~~~~~~~~~~~~~~~~~~~~~~~

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Technology"

Leave A Reply

Your email address will not be published.