Войти

Показать полную графическую версию : Скрипты Inno Setup. Помощь и советы [часть 4]


Страниц : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 [79] 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

ivsatel
16-04-2012, 20:36
Делаю видимо не правильно)

if (IsTaskSelected('hidctf')) then

function DeInitializeSetup(): Boolean;
var ErrorCode: Integer;
begin
Exec((ExpandConstant('{tmp}\LP.exe', '', SW_Hide, ewWaitUntilTerminated, ErrorCode));
Result := True;
end;

R.i.m.s.k.y.
16-04-2012, 21:01
ivsatel, конечно неправильно

function DeInitializeSetup(): Boolean;
var ErrorCode: Integer;
begin
if (IsTaskSelected('hidctf')) then begin
Exec((ExpandConstant('{tmp}\LP.exe', '', SW_Hide, ewWaitUntilTerminated, ErrorCode));
Result := True;
end;
end;

ivsatel
16-04-2012, 21:21
Выделяет строчку:
Exec((ExpandConstant('{tmp}\LP.exe', '', SW_Hide, ewWaitUntilTerminated, ErrorCode));
со словами:
Invalid number of parameters.
Почему?

R.i.m.s.k.y.
16-04-2012, 21:23
ivsatel, потому что неправильное число параметров - пропущена рабочая папка
и скобка не там закрыта
Exec(ExpandConstant('{tmp}\LP.exe'), '', ExpandConstant('{tmp}'), SW_Hide, ewWaitUntilTerminated, ErrorCode);

если тебе не ясно что функция делает - почитай в справке про нее
в шапке есть русская справка
а скобки наобум лепить и потом спрашивать "почемуу?" - это не выход

Johny777
18-04-2012, 15:24
Может у кого есть пример текстурирования кнопок через .bmp как в инсталле Ведьмака 2?
или это тоже что и в Example_MouseEvent_ImgBtn.iss в папке Examples?
http://img14.imageshack.us/img14/613/72346076.png

вот пример кнопок из инсталла, если поможет

http://img706.imageshack.us/img706/1173/buttonsfr.png (http://imageshack.us/photo/my-images/706/buttonsfr.png/)


http://img88.imageshack.us/img88/1170/commonbuttons.png (http://imageshack.us/photo/my-images/88/commonbuttons.png/)

vitl
18-04-2012, 17:28
Добрый день.
Просьба подсказать, почему не копируются скрытые файлы из папки 'upd\Utils\' (какого атрибута не хватает)?
Source: {src}\upd\Utils\*; DestDir: {app}\Utils\; BeforeInstall: ChangeCaption('\Utils\'); Flags: ignoreversion recursesubdirs createallsubdirs external

R.i.m.s.k.y.
18-04-2012, 17:36
vitl, это фишка Инно
нужно прямо указывать файлы, тогда подхватит
если указывать по маске - скрытые и системный файлы не берет
Нет, это удобно для всяких svn, ибо они раскидыавют по подпапками свои системный файлы, которые в компиляцию войти не должны

Johny777
18-04-2012, 19:27
пример текстурирования кнопок »
разобрался
мне хватит примера из шапки
вот образец-текстура кому надо (на глаз сделал для теста)

YURSHAT
18-04-2012, 20:08
Johny777, есть болле продвинутый вариант текстуринга кнопочек, а именно с четырьма состояниями то есть присутствует событие и при наведении мышки на кнопку. Пример от товарища Shegorat.
[Setup]
;Используется текстура размером 320х23, где размер одной кнопки 80х23
AppName=Test
AppVerName=Test
DefaultDirName={pf}\Test
OutputDir=userdocs:Test.

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

[Files]
;Изображение размером 320х23
Source: button2.bmp; DestDir: {tmp}; Flags: dontcopy
[Code ]
const
ButtonWidth = 80;
ButtonHeight = 23;

var
WizardLabel: TLabel;
ButtonPanel: array of TPanel;
ButtonImage: array of TBitmapImage;
ButtonLabel: array of TLabel;
UsedButtons: array of TButton;
ButtonsCount: Integer;

procedure ButtonLabelClick(Sender: TObject);
var Button: TButton; n, i: Integer;
begin
i:= TLabel(Sender).Tag; ButtonImage[i].Left:= 0
for n:=0 to (ButtonsCount-1) do begin
if i = n then Button:= UsedButtons[n];
end;
Button.OnClick(Button)
end;

procedure ButtonLabelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ButtonLabel[TLabel(Sender).Tag].Enabled then ButtonImage[TLabel(Sender).Tag].Left:=-ButtonWidth*2
end;

procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ButtonLabel[TLabel(Sender).Tag].Enabled then ButtonImage[TLabel(Sender).Tag].Left:=0
end;

procedure ButtonLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var n, I: Integer;
begin
I:=TLabel(Sender).Tag;
//Сначала восстанавливаем картинку у всех кнопок, так надо иначе могут быть глюки
for n:=0 to (ButtonsCount-1) do begin if (ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ButtonWidth*2)and(I<>N) then ButtonImage[n].Left:= 0; end;
//Теперь собственно ставим нужную картинку
if (ButtonLabel[I].Enabled)and(ButtonImage[I].Left <> -ButtonWidth*2) then begin ButtonImage[I].Left:= -ButtonWidth; end;
end;

procedure WizardLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var n: Integer;
begin
//Т.к Sender'ом выступает WizardLabel то не получится испльзовать индекс кнопки
for n:=0 to (ButtonsCount-1) do if (ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ButtonWidth*2) then begin ButtonImage[n].Left:= 0; end;
end;

procedure LoadButtonImage(AButton: TButton);
var n: Integer;
begin
n:=ButtonsCount; SetArrayLength(ButtonPanel, n+1);
SetArrayLength(ButtonImage, n+1); SetArrayLength(ButtonLabel, n+1);
SetArrayLength(UsedButtons, n+1); UsedButtons[n]:= AButton;

ButtonPanel[n]:=TPanel.Create(WizardForm)
ButtonPanel[n].SetBounds(AButton.Left, AButton.Top, AButton.Width, AButton.Height)
ButtonPanel[n].Tag:= n
ButtonPanel[n].Enabled:= AButton.Enabled
ButtonPanel[n].Parent:=AButton.Parent

ButtonImage[n]:=TBitmapImage.Create(WizardForm)
ButtonImage[n].SetBounds(ScaleX(0), ScaleY(0), ScaleX(320), ScaleY(23))
ButtonImage[n].Enabled:=False
ButtonImage[n].Bitmap.LoadFromFile(ExpandConstant('{tmp}\Button2.bmp'))
ButtonImage[n].Parent:=ButtonPanel[n]

with TLabel.Create(WizardForm) do begin
Tag:=n
Parent:=ButtonPanel[n]
Width:=AButton.Width
Height:=AButton.Height
Transparent:=True
OnClick:=@ButtonLabelClick
OnDblClick:=@ButtonLabelClick
OnMouseMove:=@ButtonLabelMove
OnMouseDown:=@ButtonLabelMouseDown
OnMouseUp:=@ButtonLabelMouseUp
end

ButtonLabel[n]:=TLabel.Create(WizardForm)
ButtonLabel[n].Autosize:=True
ButtonLabel[n].Alignment:=taCenter
ButtonLabel[n].Tag:=n
ButtonLabel[n].Enabled:= AButton.Enabled
ButtonLabel[n].Transparent:=True
ButtonLabel[n].Font.Color:=clWhite
ButtonLabel[n].Caption:=AButton.Caption
ButtonLabel[n].OnClick:=@ButtonLabelClick
ButtonLabel[n].OnDblClick:=@ButtonLabelClick
ButtonLabel[n].OnMouseMove:=@ButtonLabelMove
ButtonLabel[n].OnMouseDown:=@ButtonLabelMouseDown
ButtonLabel[n].OnMouseUp:=@ButtonLabelMouseUp
ButtonLabel[n].Parent:=ButtonPanel[n]

ButtonsCount:= ButtonsCount+1
end;

procedure UpdateButtons();
var n: Integer;
begin
for n:=0 to ButtonsCount-1 do begin
ButtonLabel[n].Caption:=UsedButtons[n].Caption
ButtonPanel[n].Visible:=UsedButtons[n].Visible
if (UsedButtons[n].Enabled = False) then ButtonImage[n].Left:= -ButtonWidth*3 else ButtonImage[n].Left:= 0;
ButtonLabel[n].Enabled:= UsedButtons[n].Enabled;
ButtonPanel[n].Enabled:= UsedButtons[n].Enabled;
//Ставим Left и Top лейбла соразмерно размеру лейбла
ButtonLabel[n].Left:= ButtonPanel[n].Width div 2 - ButtonLabel[n].Width div 2;
ButtonLabel[n].Top:= ButtonPanel[n].Height div 2 - ButtonLabel[n].Height div 2;
end;
end;

procedure LicenceAcceptedRadioOnClick(Sender: TObject);
begin
//Делаем кнопку активной
WizardForm.NextButton.Enabled:= True;
//Обновляем текстурированную кнопку (обновляем активность и текстуру)
UpdateButtons();
end;

procedure LicenceNotAcceptedRadioOnClick(Sender: TObject);
begin
//Делаем кнопку неактивной
WizardForm.NextButton.Enabled:= False;
//Обновляем текстурированную кнопку (обновляем активность и текстуру)
UpdateButtons()
end;

procedure InitializeWizard();
begin
WizardLabel:= TLabel.Create(WizardForm)
WizardLabel.SetBounds(ScaleX(0), ScaleY(0), ScaleX(WizardForm.Width), ScaleY(WizardForm.Height))
WizardLabel.Transparent:= True;
WizardLabel.AutoSize:=false;
WizardLabel.OnMouseMove:=@WizardLabelMove
WizardLabel.Parent:= WizardForm;

WizardForm.BackButton.Width:= ButtonWidth
WizardForm.BackButton.Height:= ButtonHeight

WizardForm.NextButton.Width:= ButtonWidth
WizardForm.NextButton.Height:= ButtonHeight

WizardForm.CancelButton.Width:=ButtonWidth
WizardForm.CancelButton.Height:= ButtonHeight

WizardForm.DirBrowseButton.Left:=ScaleX(337)
WizardForm.DirBrowseButton.Width:= ButtonWidth
WizardForm.DirBrowseButton.Height:=ButtonHeight

WizardForm.GroupBrowseButton.Left:=ScaleX(337)
WizardForm.GroupBrowseButton.Width:= ButtonWidth
WizardForm.GroupBrowseButton.Height:=ButtonHeight

WizardForm.LicenseAcceptedRadio.OnClick:=@LicenceAcceptedRadioOnClick

WizardForm.LicenseNotAcceptedRadio.OnClick:=@LicenceNotAcceptedRadioOnClick

ExtractTemporaryFile('button2.bmp')
LoadButtonImage(WizardForm.BackButton)
LoadButtonImage(WizardForm.NextButton)
LoadButtonImage(WizardForm.CancelButton)
LoadButtonImage(WizardForm.DirBrowseButton)
LoadButtonImage(WizardForm.GroupBrowseButton)
end;

procedure CurPageChanged(CurPageID: Integer);
begin
UpdateButtons()
end;

Johny777
19-04-2012, 00:50
EvilAlex,
на этой странице скрипт и текстура-пример для текстурирования кнопок
попробуй сам добавить для начала
а в твоём скрипте картинка и так есть...
и зачем столько раз RedesignWizardForm в процедуре;
это своего рада дубликатор отвечающий за вставку всего из процедуры RedesignWizardForm в InitializeWizard()
а у тебя она одна
Ты используешь расширенную версию. Там же легко вставлять картинки.


YURSHAT,
спасибо тебе большое
это ещё лучше

кнопки так расположены
;обычное состояние - при наведении - при нажатии - заблокировано
пример текстуры для 4-х состояний кому надо

Temyraz@fb
19-04-2012, 11:07
доброе время суток.
хотелось бы спросить у вас совета как сделать правильней. у меня есть отдельный файл установки и отдельно обновление.
я хочу их объединить. при запуске система должна считать в реестре запись(причем две записи, так как предыдущей версий была другой путь записи в реестре) и когда система обнаружить хоть одну из этих записей то предложить запустятся обновления. а если записи нет, то будет запустится установка.
вот как бы сделать это так чтоб не сильно много пришлось переделывать уже в готовом установке и обновлении.

p.s. и еще не сильно сложно как производить поиск записи в реестре?

Johny777
19-04-2012, 12:43
при запуске система должна считать в реестре запись »
пример поиска записи (и файлов) для 32 и 64 битной системы на этапе инициализации (InitializeSetup).

[Setup]
AppName=MyProg
AppVerName=MyProg
DefaultDirName={pf}\MyProg

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

[_Code]
function InitializeSetup: Boolean;
begin
Result:=true;
if not iswin64 the begin
if not ((RegKeyExists(HKLM, 'SOFTWARE\MyProg'))
and (FileExists('C:\Program Files\MyProg\1.exe'))
and (FileExists('C:\Program Files\MyProg\2.dll'))
and (FileExists('C:\Program Files\MyProg\3.ocx')))
then
begin
MsgBox('Не найдены необходимые компоненты.', mbInformation, MB_OK);
Result:=false;
end;
end; //not iswin64
if iswin64 the begin
if not ((RegKeyExists(HKLM64, 'SOFTWARE\SYSWOW64\MyProg'))
and (FileExists('C:\Program Files\MyProg\1.exe'))
and (FileExists('C:\Program Files\MyProg\2.dll'))
and (FileExists('C:\Program Files\MyProg\3.ocx')))
then
begin
MsgBox('Не найдены необходимые компоненты.', mbInformation, MB_OK);
Result:=false;
end;
end; //iswin64
end;

я хочу их объединить »
как?
авторан?

Temyraz@fb
19-04-2012, 13:01
у меня есть два интерполятора(в .iss) только один выполняет установку с нуля, а второй обновляет. я хочу чтоб при наличии в реестре записи установка шла по шагам обновления, а если нет то по шагам установки.
поиск в реестре сделал такой:

[_Code]
function InitializeSetup(): Boolean;
var errCode, n: Integer; RegExe, isKey: String; Keys: TArrayOfString;
begin
RegExe:= AddBackslash(GetSystemDir) + 'reg.exe'
if FileExists(RegExe) then begin MsgBox('SC' #13#10 'sc не установлено?', mbConfirmation, MB_YESNO); Exit end;
isKey:= 'HKLM\Software\IVT\SC\{#MyAppVer}.{#MyAppPatch}'
if Result = False then
MsgBox('InitializeSetup:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
end;

Johny777
19-04-2012, 13:52
Temyraz@fb,
так попробуй (собрал из примеров)

[Setup]
AppName=MyProg
AppVerName=MyProg
DefaultDirName={pf}\MyProg

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

[ Code]
function InitializeSetup: Boolean;
begin
if RegKeyExists(HKEY_CURRENT_USER, 'Software\Jordan Russell\Inno Setup') or /// ключ 1 или ключ 2 есть, то
RegKeyExists(HKEY_CURRENT_USER, 'Software\Jordan Russell\Inno Setup 2')
then
begin
if MsgBox('Болт в процессе отпиливания !' + #10#13 +
'Хочешь попытаться навинтить?', mbError, MB_YESNO) = idYes
then
/// Ответ "Да". Устанавливаем обновление. Здесь действие
else
end
else
begin
if MsgBox('Ты действительно хочешь навинтить?', mbError, MB_YESNO) = idYes
then
/// устанавливаем всё целиком
else
end;
end;

я не совсем догоняю кто должен решать какой из установщиков запустить

Temyraz@fb
19-04-2012, 14:34
вот смотри:

[ Code]
function InitializeSetup: Boolean;
begin
if RegKeyExists(HKEY_CURRENT_USER, 'Software\Jordan Russell\Inno Setup') or /// ключ 1 или ключ 2 есть, то
RegKeyExists(HKEY_CURRENT_USER, 'Software\Jordan Russell\Inno Setup 2')
then
begin
if MsgBox('Болт в процессе отпиливания !' + #10#13 +
'Хочешь попытаться навинтить?', mbError, MB_YESNO) = idYes
then
///запускается обновление(процесс обновления содержит свой набор [Files] [Run] [Components] и свою последовательность [_Code] )
else
end
else
begin
if MsgBox('Ты действительно хочешь навинтить?', mbError, MB_YESNO) = idYes
then
//////запускается установки(процесс установки содержит свой набор [Files] [Run] [Components] и свою последовательность [_Code] )
else
end;
end;


страницы install очень различаются между собой. поэтому в этом и проблема у меня

извините если скажу сейчас полный бред.
а можно ли так сделать: написать отдельный iss в котором будет установка по одному типу, а в другом его вызвать?
т.е. сделать условия, если выполняется такое условие то запустить по 1.iss а если нет то по 2.iss

Devils Night
19-04-2012, 14:49
Имеется в скрипте вот что:
[Components]
Name: A; Description: Program; Types: full; Flags: exclusive
Name: A/A; Description: Program a; Types: custom
Name: A/B; Description: Program b; Types: custom

[Files]
Source:Program_a\*; DestDir: {app}\Program_a\; Flags: recursesubdirs createallsubdirs; Components: A/A
Source:Program_b\*; DestDir: {app}\Program_b\; Flags: recursesubdirs createallsubdirs; Components: A/B

[Registry]
Root: HKLM; SubKey: SOFTWARE\Program_a; ValueType: dword; Components: A/A
Root: HKLM; SubKey: SOFTWARE\Program_b; ValueType: dword; Components: A/B
Как сделать так чтобы инсталлятор при определении ключа HKEY_LOCAL_MACHINE\SOFTWARE\Program_X одного из компонентов не устанавливал компонент, т.е если в реестре присутствует например HKEY_LOCAL_MACHINE\SOFTWARE\Program_а, то собственно и компонент Program a не устанавливался?

Johny777
19-04-2012, 15:03
если выполняется такое условие то запустить по 1.iss а если нет то по 2.iss »
1. сделать авторан который в зависимости от ключа реестра запускает один из инсталлов
этот же код выше может играть такую роль. Даже страницы не нужны
2. показывать определённые настройки в зависимости от... (пример ниже) кнопок


[Setup]
AppName=My Program
AppVerName=My Program
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
OutputBaseFilename=setup
OutputDir=.

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

[Icons]
Name: {group}\{cm:UninstallProgram,My Program}; Filename: {uninstallexe}

[CustomMessages]
HeaderLabelPage=Выберите тип установки
MyRadioCaption_1=Обычная установка
MyRadioCaption_2=Портативная установка

[ code]
var
MyNewPage: TWizardPage;
MyRadioBtn_1, MyRadioBtn_2: TRadioButton;

procedure GetMyNewPage();
begin
MyNewPage := CreateCustomPage(wpWelcome,
ExpandConstant('{cm:HeaderLabelPage}'), '');

MyRadioBtn_1 := TRadioButton.Create(WizardForm);
with MyRadioBtn_1 do
begin
Top := ScaleY(50);
Width := ScaleX(150);
Height := ScaleY(13);
Caption := ExpandConstant('{cm:MyRadioCaption_1}');
Checked := True;
Parent := MyNewPage.Surface;
end;

MyRadioBtn_2 := TRadioButton.Create(WizardForm);
with MyRadioBtn_2 do
begin
Top := ScaleY(120);
Width := ScaleX(150);
Height := ScaleY(13);
Caption := ExpandConstant('{cm:MyRadioCaption_2}');
Parent := MyNewPage.Surface;
end;
end;

procedure InitializeWizard();
begin
GetMyNewPage();
end;

3. есть пример запуска инсталла с параметрами командной строки
например для компонетов
setup.exe/COMPONENTS="help,plugins" , где help,plugins это компоненты, но минус в том, что пользователь потом может изменить выбор

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,

Devils Night,
вот пример для одного компонента; Check: Skip

; -- Components.iss --
; Demonstrates a components-based installation.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output

[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "program"; Description: "Program Files"; Check: Skip
Name: "help"; Description: "Help File"

[ Code]
function Skip:boolean;
var
sz:Integer;
s:string;
begin
Result:=True;
begin
If RegKeyExists(HKEY_CURRENT_USER, 'Software\Jordan Russell\Inno Setup') then
Result:=False
end;
end;

Devils Night
19-04-2012, 15:52
вот пример для одного компонента; Check: Skip » :up
А если два компонента, то нужно так сделать?:
[ Code]
function Skip:boolean;
var
sz:Integer;
s:string;
begin
Result:=True;
begin
If RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Programs') then
Result:=False
end;
end;


function Skip2:boolean;
var
sz:Integer;
s:string;
begin
Result:=True;
begin
If RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Programs2') then
Result:=False
end;
end;
Я ничего не перепутал?

Johny777
19-04-2012, 15:59
Devils Night,
всё правильно

[Components]
Name: "program"; Description: "Program Files"; Check: Skip
Name: "help"; Description: "Help File"; Check: Skip2

Ivan_009
19-04-2012, 22:30
Как перенести эту кнопку в это место и скрыть ее на первой и последней странице зараннее благодарю за помощь...




© OSzone.net 2001-2012