program selfexstub;
 
{$IFDEF WIN32}
  {$APPTYPE CONSOLE}
{$ENDIF}
 
uses
  Windows,
  StRegIni,
  AbArcTyp,
  AbUnzPrc,
  AbUtils,
  AbZipTyp,
  {$IFDEF Windows}
  WinCRT,
  {$ENDIF}
  HyperStr,
  SysUtils,
  Dialogs,
  FileCtrl;
 
type
  THelper = class
  public
    procedure UnzipProc(Sender : TObject;
                        Item : TAbArchiveItem;
                        const NewName : string);
  end;
 
procedure THelper.UnzipProc(Sender : TObject;
                            Item : TAbArchiveItem;
                            const NewName : string);
begin
  AbUnzip(Sender, TAbZipItem(Item), NewName);
end;
 
{Build this app using the Define "BuildingStub", to keep it smaller!}
 
var
  ZipArchive : TAbZipArchive;
  Helper : THelper;
  tStr: String;
  mr: Integer;
  RegIni: TStRegIni;
begin
  RegIni:= TStRegIni.Create(RIMachine, False);
  try
    WriteLn( 'Abbrevia Self Extracting Archive' );
    ZipArchive := TAbZipArchive.Create(ParamStr(0),
                                       fmOpenRead or fmShareDenyNone);
 
    RegIni.CurSubKey:= 'SOFTWARE\Microsoft\Microsoft Games\Links 2001\2.0';
 
    tStr:= RegIni.ReadString('EXE Path', '');
 
 
    if tStr = '' then begin
      if not SelectDirectory('Please pick the folder where Links 2001 is installed', '', tStr) then begin
        MessageDlg('No links path selected. Aborting', mtError, [mbOK], 0);
        Exit;
      end;
      tStr:= IncludeTrailingBackslash(tStr);
 
      if not FileExists(tStr + 'LinksLauncher.exe') then begin
        MessageDlg('Aborting patch installation. No Links EXE was found in the selected path.', mtError, [mbOK], 0);
        Exit;
      end;
 
    end else begin
      if not DirectoryExists(tStr) then begin
        MessageDlg('EXE Path ' + tstr + ' does not exist. Aborting', mtError, [mbOK], 0);
        Exit;
      end;
 
      mr:= MessageDlg('The detected Links directory is ' + tStr + '. Is this correct?', mtConfirmation, [mbYes, mbNo], 0);
      if mr <> idYes then begin
        MessageDlg('Aborting patch installation. Nothing was done to your Links installation at this point.', mtError, [mbOK], 0);
        Exit;
      end;
    end;
 
 
 
    Helper := THelper.Create;
    try
      ZipArchive.BaseDirectory:= tStr;
      ZipArchive.Load;
      ZipArchive.ExtractHelper := Helper.UnzipProc;
      ZipArchive.ExtractFiles('*.*');
    finally
      Helper.Free;
      ZipArchive.Free;
    end;
 
    tStr:= IncludeTrailingBackslash(tStr);
    mr:= MessageDlg('Do you have Links CE (Champion Edition)?', mtConfirmation, mbYesNoCancel, 0);
    if mr <> idCancel then begin
      if mr = idYes then begin
        //they said yes
        mr:= MessageDlg('Are you SURE you have Links CE (Champion Edition) and not the Standard edition?', mtConfirmation, mbYesNoCancel, 0);
        if mr = idYes then begin
          //yes, ce
          if WaitExec(tStr + 'CEPATCH.EXE', SW_SHOWNORMAL) = -1 then begin
            MessageDlg('Error launching extracted program', mtError, [mbOK], 0);
          end;
        end;
      end else begin
        mr:= MessageDlg('Are you SURE you have Links standard edition and NOT Links CE (Champion Edition)?', mtConfirmation, mbYesNoCancel, 0);
        if mr = idYes then begin
          //yes, std
          if WaitExec(tStr + 'STDPATCH.EXE', SW_SHOWNORMAL) = -1 then begin
            MessageDlg('Error launching extracted program', mtError, [mbOK], 0);
          end;
        end;
      end;
    end;
 
    DeleteFile(tStr + 'CEPATCH.EXE');
    DeleteFile(tStr + 'STDPATCH.CHR');
  finally
    FreeAndNil(RegIni);
  end;
end.
1
Hosted by www.Geocities.ws