Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Johny777

Ветеран


Сообщения: 649
Благодарности: 444

Профиль | Отправить PM | Цитировать


хотелось бы реализовать следующее
устанавливаются например 3 компонента из установщика
half life 2
half life 2 episode one
half life 2 episode two
уникальные файлы для каждой игры каждый в свою папку
общие файлы для всех файлов в общую - корневую
например
pf/Orange Box/half life 2/run_hl2.exe
pf/Orange Box/half life 2 ep1/run_hl2_ep1.exe
pf/Orange Box/source 2007 binaries 2.gcf
pf/Orange Box/source models.gcf
итд

логика такая
- Autorun с функцией поиска через реестр узнаёт куда установилась игра (думаю нужно в основном установщике в секции [Setup] задействовать параметр AppId
- потом, в директории игры ищет например app/half life 2/run_hl2.exe, и если он есть то появлялась кнопка запустить игру .Eсли его нет то кнопка неактивна или её нет

желательно что бы этот Autorun был бы не частью основного установщика и не было проблемы, что игру удалили вручную, а он предлагает запустить вместо того чтобы установить
в коде для описания компонентов видел функцию поиска файла
может подобная функция и нужна
function IsComponent3:boolean;
var
sz:Integer;
s:string;
begin
Result:=True;
begin
If (FileSearch('manual.txt', ExpandConstant('{src}\main'))='') then
Result:=False
end;
end;

есть уже почти готовый на одну игру
но адаптировать его мне не позволяет незнание паскаля
[Setup]
Код: Выделить весь код
SourceDir=.
OutputDir=Setup
AppName=preInstaller
AppVerName=preInstaller
AppVersion=preInstaller
CreateAppDir=false
OutputBaseFilename=preInstaller
DiskSpanning=false

DisableDirPage=true
DisableFinishedPage=true
DisableProgramGroupPage=true
DisableReadyPage=true
Uninstallable=false

[Messages]
SetupAppTitle=AutoRUN

[Languages]
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

[Files]
Source: ISSkin.dll; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: steam.cjstyles; DestDir: {tmp}; Flags: ignoreversion dontcopy nocompression
Source: 1.bmp; Flags: dontcopy

(Code)
procedure LoadSkin(lpszPath: String; lpszIniFileName: String); external 'LoadSkin@files:isskin.dll stdcall';
procedure UnloadSkin(); external 'UnloadSkin@files:isskin.dll stdcall';
function ShowWindow(hWnd: Integer; uType: Integer): Integer; external 'ShowWindow@user32.dll stdcall';

function InitializeSetup:boolean;
begin
  ExtractTemporaryFile('steam.cjstyles');
  LoadSkin(ExpandConstant('{tmp}')+'\steam.cjstyles', '');
  Result:=True;
end;

procedure DeinitializeSetup;
begin
  ShowWindow(WizardForm.Handle,0);
  UnloadSkin();
end;
////////////////////////////////////////////////////////////////////////

const
  BM_CLICK    = $00F5;

var
  AutoRun: TSetupForm;
  img1: TBitmapImage;
  PlayButton, InstallButton, SupportButton, ReadmeButton, WebButton, ExitButton, UninstallButton: TButton;
  AppPath,UninsPath: string;
  ResultCode: Integer;
procedure CurPageChanged(CurPageID: Integer);
begin
  If CurPageID=wpWelcome then
  SendMessage(WizardForm.NextButton.Handle, BM_CLICK, 0, 0);
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
 Confirm:=False
 Cancel:=True
end;

procedure PlayButtonClick(Sender: TObject);
var
  exe: string;
begin
  exe:='shift.exe';
  if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\se15_is1','Install Dir', AppPath) then
  begin
    Exec(AddBackslash(AppPath) + Exe, '', ExtractFilePath(AddBackslash(AppPath) + Exe), SW_SHOWNORMAL,ewNoWait,ResultCode)
  AutoRun.Close;
  PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
  end
end;

procedure InstallButtonClick(Sender: TObject);
var
  CurPageID: Integer;
begin
  Exec(ExpandConstant('{src}\Setup.exe'),'','',SW_SHOW,ewNoWait,ResultCode)
  AutoRun.Close;
  PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
end;

procedure SupportButtonClick(Sender: TObject);
begin
  shellexec('open', ExpandConstant('{src}\Game.exe'), '', '',SW_SHOWNORMAL, ewnowait, ResultCode)
end;

procedure ReadmeButtonClick(Sender: TObject);
begin
  ShellExec('open', ExpandConstant('{src}\readme.txt'),'','', SW_SHOW, ewNoWait, ResultCode)
end;

procedure WebButtonClick(Sender: TObject);
begin
  shellexec('open', 'http://localhost', '', '',SW_SHOWNORMAL, ewnowait, ResultCode)
end;

procedure ExitButtonClick(Sender: TObject);
var
  CurPageID: Integer;
begin
  AutoRun.Close;
  PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
end;

procedure UninstallButtonClick(Sender: TObject);
begin
if RegQueryStringValue(HKLM, 'SOFTWARE\Game','UninstallString', UninsPath) then
  begin
    UninsPath:=RemoveQuotes(UninsPath)
    Exec(UninsPath,'','',SW_SHOWNORMAL,ewNoWait,ResultCode)
    AutoRun.Close;
    PostMessage(WizardForm.CancelButton.Handle, BM_CLICK, 0, 0);
  end
end;

procedure CreateAutoRun;
begin
  //AutoRun
  AutoRun := CreateCustomForm;
  with AutoRun do begin
    Left := 498;
    Top := 75;
    Width := 495;
    Height := 340;
    BorderIcons := [];
    BorderStyle:=bsToolWindow //(bsNone, bsSingle, bsSizeable, bsDialog, bsToolWindow, bsSizeToolWin)
    Color := clBtnFace;
    Font.Color := clWindowText;
    Font.Height := -11;
    Font.Name := 'MS Sans Serif';
    Font.Style := [];
    Position := poScreenCenter;
    Caption:='AutoRUN'
  end;
  //img1
  img1 := TBitmapImage.Create(AutoRun);
  ExtractTemporaryFile('1.bmp');
  with img1 do begin
    Parent := AutoRun;
    Left := 0;
    Stretch:= true;
    Top := 0;
    Width := Autorun.Width;
    Height := Autorun.Height;
    Bitmap.LoadFromFile(ExpandConstant('{tmp}\1.bmp'));
  end;
  //PlayButton
  PlayButton:= TButton.Create(AutoRun);
  with PlayButton do begin
    Parent := AutoRun;
    Left := 300;
    Top := 110;
    Width := 150;
    Height := 22;
    Caption:= 'Íà÷àòü èãðó';
    Cursor:= crHand;
  // ModalResult:= mrOk;
    OnClick := @PlayButtonClick;
    if not RegQueryStringValue(HKLM, 'SOFTWARE\Game','Install Dir', AppPath) then
  begin
    PlayButton.Enabled := False;
  end;
  end;
  //InstallButton
  InstallButton:= TButton.Create(AutoRun);
  with InstallButton do begin
    Parent:= AutoRun;
    Left := 300;
    Top := 110;
    Width := 150;
    Height := 22;
    Caption:= 'Óñòàíîâèòü èãðó';
    Cursor:= crHand;
    OnClick := @InstallButtonClick;
  end;
  //SupportButton
  SupportButton:= TButton.Create(AutoRun);
  with SupportButton do begin
    Parent:= AutoRun;
    Left := 300;
    Top := 140;
    Width := 150;
    Height := 22;
    Caption:= 'Èíôî';
    Cursor:= crHand;
    OnClick := @SupportButtonClick;
  end;
  //ReadmeButton
  ReadmeButton:= TButton.Create(AutoRun);
  with ReadmeButton do begin
    Parent:= AutoRun;
    Left := 300;
    Top := 170;
    Width := 150;
    Height := 22;
    Caption:= 'Readme';
    Cursor:= crHand;
    OnClick := @ReadmeButtonClick;
  end;
  //WebButton
  WebButton:= TButton.Create(AutoRun);
  with WebButton do begin
    Parent:= AutoRun;
    Left := 300;
    Top := 200;
    Width := 150;
    Height := 22;
    Caption:= 'Âåá-ñàéò';
    Cursor:= crHand;
    OnClick := @WebButtonClick;
  end;
  //ExitButton
  ExitButton:= TButton.Create(AutoRun);
  with ExitButton do begin
    Parent:= AutoRun;
    Left := 300;
    Top := 260;
    Width := 150;
    Height := 22;
    Caption:= 'Âûõîä';
    Cursor:= crHand;
    OnClick := @ExitButtonClick;
//    ModalResult:= mrCancel;
  end;
  //UninstallButton
  UninstallButton:= TButton.Create(AutoRun);
  with UninstallButton do begin
    Parent:= AutoRun;
    Left := 300;
    Top := 230;
    Width := 150;
    Height := 22;
    Caption:= 'Óäàëèòü èãðó';
    Cursor:= crHand;
    OnClick := @UninstallButtonClick;
  end;

  if not RegQueryStringValue(HKLM, 'SOFTWARE\Game','UninstallString', UninsPath) then
  begin
    InstallButton.Enabled:=true;
    InstallButton.Visible:=true;
    UninstallButton.Enabled:=false;
    UninstallButton.Visible:=false;
  end;
  if RegQueryStringValue(HKLM, 'SOFTWARE\Game','UninstallString', UninsPath) then
  begin
    InstallButton.Enabled:=false;
    InstallButton.Visible:=false;
    UninstallButton.Enabled:=true;
    UninstallButton.Visible:=true;
  end;

  AutoRun.ShowModal;
end;

procedure InitializeWizard;
begin
  WizardForm.BeveledLabel.Enabled:=True;
  CreateAutoRun;
end;

заранее спасибо за помощь!

Последний раз редактировалось Johny777, 25-01-2012 в 14:36. Причина: добавлен код


Отправлено: 19:33, 24-01-2012 | #672